tars服務之mysql安裝介紹

1、解壓mysql

mv mysql-5.6.26.tar.gz /usr/local/

tar zxvf mysql-5.6.26.tar.gz

cd /usr/local/mysql-5.6.26

執行

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.26 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

執行

make  //比較耗時
make install

2、接著執行

groupadd mysql
useradd -g mysql mysql

chown mysql:mysql ../mysql-5.6.26
ln -s /usr/local/mysql-5.6.26 /usr/local/mysql

3、繼續一行行復制粘貼執行

yum install perl
rm -rf /usr/local/mysql/data
mkdir -p /data/mysql-data
ln -s /data/mysql-data /usr/local/mysql/data
chown -R mysql:mysql /data/mysql-data /usr/local/mysql/data

cp support-files/mysql.server /etc/init.d/mysql
**如果/etc/目錄下有my.cnf存在,需要把這個配置刪除瞭**
rm /etc/my.cnf

4、

cd /usr/local/mysql-5.6.26
yum install -y perl-Module-Install.noarch
perl scripts/mysql_install_db --user=mysql

5、修改my.cnf

vim /usr/local/mysql/my.cnf

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
# port = .....
socket = /tmp/mysql.sock

bind-address=127.0.0.1

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

6、啟動和關閉mysql

cd /etc/init.d
chmod u+x mysql
啟動mysql
service mysql start
chkconfig mysql on
結束mysql
service mysql stop

7、修改環境變量

vim /etc/profile  //修改環境變量

在環境變量末尾加入

PATH=$PATH:/usr/local/mysql/bin


#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_171
JRE_HOME=/usr/java/jdk1.8.0_171/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
MAVEN_HOME=/home/py/tarsframe/apache-maven-3.3.9
PATH=$PATH:$JAVA_HOME/bin:/home/py/tarsframe/cmake-3.9.0/bin:$JRE_HOME/bin:$MAVEN_HOME/bin:/sbin
export JAVA_HOME JRE_HOME CLASS_PATH MAVEN_HOME PATH

此次環境變量將mysql,jdk,maven,cmake一並修改完成

source /etc/profile

8、下面密碼為mysql密碼

service mysql start
cd /etc/init.d
mysqladmin -u root password '密碼'//添加root密碼
mysql --user=root --password=密碼
grant all privileges on *.* to 'root'@'%' identified by '密碼';
flush privileges;

發佈留言