centos7.2安裝MYSQL5.7
1、解除安裝系統自帶的 mariadb-lib
1)#rpm -qa|grep mariadb
2)# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
3)#rpm -qa|grep mariadb
2、安裝 wget
#yum install wget -y
3、下載mysql5.7.16 rpm安裝包,官網最新的mysql安裝包是mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar下載地址
#wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
4、解壓
#tar -xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar
5、依次安裝:
1)#rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
2)#rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
3)#rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
4)#rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
第4)步的時候可能會報錯:
warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
ibaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
net-tools is needed by mysql-community-server-5.7.16-1.el7.x86_64(可能沒有這個)
需要安裝:
1)libaio-0.3.107-10.el6.x86_64.rpm
1)#wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
2)#rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
2)yum install net-tools -y
5)繼續安裝(如果第4)步沒有錯,就不用)
#rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm
6、資料庫初始化
1)#mysqld --initialize --user=mysql
2)找密碼,紅色區域
1)# cat /var/log/mysqld.log
[Note] A temporary password is generated for [email protected]: )1r3gi,hjgQa
7、現在啟動mysql資料庫
1)#systemctl start mysqld.service
2)# mysql -uroot -p
8、修改密碼、許可權
1)#ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
2)#GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
3)#flush privileges;
9、開放埠
1)#firewall-cmd --zone=public --add-port=3306/tcp --permanent
2)#firewall-cmd --reload
10、完成
附:
啟動/停止/重啟MySQL
1)啟動:service mysqld start
2)停止:service mysqld stop
3)重啟:service mysqld restart