1.删除mysql
yum remove mysql mysql-server mysql-libs mysql-server;
find / -name mysql 将找到的相关东西delete掉(rm -rf /var/lib/mysql);
rpm -qa|grep mysql(查询出来的东东yum remove掉)
2.下载 wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
3.安装 rpm -ivh mysql-community-release-el6-5.noarch.rpm
yum update yum install mysql-server(这里有报错 *** Requires: libc.so.6(GLIBC_2.17)(64bit) ***)
解决:
3.1、yum install glibc.i686
3.2、yum list libstdc++*
3.3、#cd /etc/yum.repos.d/
#sudo vi mysql-community.repo
找到mysql-56-community
将enable置为0 enable=0
重新安装mysql sudo yum install mysql-server
4.查看mysql状态---- /etc/rc.d/init.d/mysqld status
启动mysql----/etc/rc.d/init.d/mysqld start
登录-----mysql -u root -p 空密码
修改密码 use mysql; UPDATE user SET password=PASSWORD('123456') WHERE user='root';
刷新----flush privileges; 退出 exit;
5.开放3306端口, vi /etc/sysconfig/iptables
添加-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
重启 service iptables restart
6.可能远程无法连接
登录 use mysql;
查询root和主机的关系 select Host,User from user;
修改update user set Host='%' where User ='root' limit 3; ----%表示任意
这里可能会报错----ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
直接跳过,执行flush privileges; 退出
重启mysql---- service mysqld restart(我没有重启也可以访问了)。
相关参考:https://www.cnblogs.com/nucdy/p/5784809.html
http://www.runoob.com/mysql/mysql-install.html
https://blog.csdn.net/qq_32851561/article/details/81146314
https://blog.csdn.net/hello_world_qwp/article/details/79544162