RedHat系統自行搞定yum配置。node
[root@vultr ~]# yum list installed | grep mysql
mysql-libs.x86_64 5.1.73-8.el6_8 @CentOS/6.10
複製代碼
[root@vultr ~]# yum -y remove mysql-libs.x86_64
複製代碼
[root@vultr ~]# rpm -qa | grep -i mysql
-i: 匹配時不區分大小寫。
1) 若是有rpm包安裝的MySQL,使用如下命令刪除:
[root@vultr ~]# rpm -e --nodeps 包名
2) 查找以前老版本MySQL的目錄,文件而且刪除
[root@vultr ~]# find / -name mysql
[root@vultr ~]# rm -rf 目錄
[root@vultr ~]# rm -rf /etc/my.cnf # 須要手動刪除my.cnf文件
3) 再次查找機器是否安裝了MySQL
[root@vultr ~]# rpm -qa | grep -i mysql
複製代碼
[root@vultr ~]# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
複製代碼
[root@vultr ~]# rpm -ivh mysql-community-release-el6-5.noarch.rpm
Preparing... ########################################### [100%]
1:mysql-community-release########################################### [100%]
複製代碼
由於6.x系統yum安裝MySQL的話,是安裝的5.1,因此須要手動更改yum信息。 實際是安裝兩個yum源文件,執行後在/etc/yum.repos.d/會多出兩個文件:mysql-community.repo和mysql-community-source.repo。mysql
[root@vultr ~]# yum repolist all | grep mysql
...[省略部份內容]
mysql55-community-source MySQL 5.5 Community Server - Sour 禁用
mysql56-community MySQL 5.6 Community Server 啓用: 512
mysql56-community-source MySQL 5.6 Community Server - Sour 禁用
...[省略部份內容]
複製代碼
能夠看到mysql56-community是啓用的sql
[root@vultr ~]# yum install -y mysql-community-server
複製代碼
等待安裝...bash
[root@vultr ~]# service mysqld start
複製代碼
首次登陸時尚未設置密碼,直接mysql -u root登陸便可。tcp
[root@vultr ~]# mysql -u root
複製代碼
mysql> use mysql
mysql> update user set password=password('你的密碼') where user='root';
mysql> grant all privileges on *.* to ‘root’@’%’ identified by ‘你的密碼’ with grant option;
mysql> flush privileges;
複製代碼
[root@vultr ~]# vi /etc/sysconfig/iptables
添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
:wq保存退出
[root@vultr ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
複製代碼
[root@vultr ~]# chkconfig mysqld on
複製代碼