一、升级操作
1、卸载旧版本
- 查看MySQL旧版本
rpm -qa|grep mysql
rpm -qa|grep mariadb
- 卸载MySQL
rpm -e --nodeps mysql-5.1.73-7.el6.x86_64 rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64 rpm -qa|grep mysql
- 删除数据目录
ls -l /var/lib|grep mysql rm -rf /var/lib/mysql
数据目录可以备份移走。mysqld服务在初始化时会检查数据目录是否存在:如果数据目录不存在,mysqld则会创建它;如果数据目录存在,且不是空目录(即包含有文件或子目录),mysqld会显示一条错误信息并中止:
[ERROR] --initialize specified but the data directory exists. Aborting.
2、安装MySQL5.6
- 准备好MySQL的安装包
MySQL-client-5.6.30-1.el6.x86_64.rpm
MySQL-devel-5.6.30-1.el6.x86_64.rpm
MySQL-server-5.6.30-1.el6.x86_64.rpm
- 安装MySQL包
rpm -ivh MySQL-client-5.6.30-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.30-1.el6.x86_64.rpm rpm -ivh MySQL-server-5.6.30-1.el6.x86_64.rpm
3、初始化数据库
- 启动数据库
[[email protected] software]# /etc/init.d/mysql start
Starting MySQL [ OK ]
[[email protected] software]#
- 检查数据库运行状态
[[email protected] software]# /etc/init.d/mysql status
MySQL running (5753) [ OK ]
至此可以判断MySQL基本安装成功了!!!!
- 找到临时密码
[[email protected] software]# more /root/.mysql_secret
# The random password set for the root user at Wed Sep 28 15:55:25 2016 (local time): LSM8vTnqNGr9ArQs
- 登陆修改密码
mysql> SET PASSWORD=PASSWORD(‘Atae123$‘);
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
4、设置root用户远程访问
- 设置root远程访问
use mysql;
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘[email protected]‘ WITH GRANT OPTION; ‘%‘代表任意地址,也可以指定IP
select host, user from user;
FLUSH PRIVILEGES;
- 设置防火墙
在-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited之前,添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- 重启防火墙
service iptables restart