系統(tǒng)環(huán)境:centos7.4
一,查看是否安裝有數(shù)據(jù)庫:
yum list installed | grep mysqld/mariadb
二,安裝centos7系統(tǒng)帶有mysql5.6安裝包的yum源RPM資源包:
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm yum clean all yum repolist
三,安裝msyql5.6:
yum -y install mysql-community-server
四,啟動服務(wù):
systemctl start mysqld systemctl enable mysqld
五,重置密碼:是具體情況而定(可以省略,無密碼登陸)
#mysql_secure_installation Set root password? [Y/n] y [設(shè)置root用戶密碼] Remove anonymous users? [Y/n] y [刪除匿名用戶] Disallow root login remotely? [Y/n] n [禁止root遠程登錄] Remove test database and access to it? [Y/n] y [刪除test數(shù)據(jù)庫] Reload privilege tables now? [Y/n] y [刷新權(quán)限]
六,查看mysql版本:
mysql -V mysql Ver 14.14 Distrib 5.6.39, for Linux (x86_64) using EditLine wrapper
七,驗證:(無密碼)
mysql -uroot -p 密碼
八、設(shè)置密碼和遠程權(quán)限
數(shù)據(jù)庫密碼設(shè)置:#set password for 'root'@'localhost'=password('userpasswd');
九、配置防火墻
firewall-cmd --zone=public --add-port=3306/tcp --permanent