1. 查看CentOS自帶MySQL 5.1組件並卸載。node
rpm -qa | grep -i mysql mysql
rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64 等sql
cd /var/lib/mysql安全
rm -rf * 刪除原先配置
bash
檢查依賴包 rpm -qa | grep -i numactltcp
2. 安裝MySQL(下面的安裝順序不能錯,不然會安裝失敗)ide
rpm -ivh mysql-community-common-5.7.11-1.el6.i686.rpm spa
rpm -ivh mysql-community-libs-5.7.11-1.el6.i686.rpmcode
rpm -ivh mysql-community-client-5.7.11-1.el6.i686.rpmserver
rpm -ivh mysql-community-server-5.7.11-1.el6.i686.rpm
3. 啓動MySQL service mysqld start
得到MySQL初始密碼
grep 'temporary password' /var/log/mysqld.log
2016-02-22T10:46:50.930703Z 1 [Note] A temporary password is generated for root@localhost: iwrg=PsNO86Y
使用上一步得到的密碼登陸MySQL,並修改初始密碼
mysql -uroot -p'初始密碼'
alter user 'root'@'localhost' identified by 'UYmi@191';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ' password' WITH GRANT OPTION;
flush privileges
;
mysql -h ipaddress-uroot -p'password'
以上,MySQL 5.7.11安裝完成。且能遠程訪問。通常簡單到此安裝結束。
1.以後還能夠放開防火牆、設定自啓動、加強MySQL安全設置等。
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
2./etc/init.d/iptables save
3.chkconfig mysqld on
4.mysql_secure_installation