在linux(Centos 7以上版本親測)上安裝mysql5.6

聽雨巷賣杏花發表於2018-12-08

Mysql的安裝:

1.登入伺服器,依次輸入以下命令進行安裝
cd /usr/local
2.下載安裝包並解壓
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
2.1.新增使用者組 groupadd mysql
2.2.新增使用者mysql 到使用者組mysql
useradd -g mysql mysql
2.3安裝
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql 如果執行報錯
[root@dc1atmpapp12 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
解決方法是安裝autoconf庫
執行命令:yum -y install autoconf
正確執行上面命令以後
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
2.4.修改啟動指令碼
vi /etc/init.d/mysqld
2.4.1修改項:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
2.5.啟動服務
service mysqld start
2.6加入環境變數,編輯 /etc/profile,這樣可以在任何地方用mysql命令了 export PATH=$PATH:/usr/local/mysql//bin
source /etc/profile
2.7.測試連線
./mysql/bin/mysql -uroot
2.8.啟動mysql
service mysqld start
service mysqld status
2.9.建立使用者修改root密碼並授權
Mysql -uroot -p
set password=password('root');
FLUSH PRIVILEGES;
grant all privileges on *.* to root@"%" identified by 'root' with grant option;
FLUSH PRIVILEGES;

請順序執行,食用更加

相關文章