1.先下载mysql5.6的rpm 

链接:https://pan.baidu.com/s/1atBhYURE_EPOVgS6TGEnXQ 密码:8nzq

2.将mysql文件上传至虚拟机

3. 查看centos安装的mysql

[[email protected] local]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64

4.卸载mysql

[[email protected] local]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

5.解压mysql

[[email protected] mysql]# tar -xvf MySQL-5.6.39-1.el6.x86_64.rpm-bundle.tar 
MySQL-embedded-5.6.39-1.el6.x86_64.rpm
MySQL-test-5.6.39-1.el6.x86_64.rpm
MySQL-shared-5.6.39-1.el6.x86_64.rpm
MySQL-server-5.6.39-1.el6.x86_64.rpm
MySQL-devel-5.6.39-1.el6.x86_64.rpm
MySQL-client-5.6.39-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.39-1.el6.x86_64.rpm

6.通过rpm -ivh安装(按照顺序)

[[email protected] mysql]# rpm -ivh MySQL-client-5.6.39-1.el6.x86_64.rpm 

[[email protected] mysql]# rpm -ivh MySQL-devel-5.6.39-1.el6.x86_64.rpm 

[[email protected] mysql]# rpm -ivh MySQL-server-5.6.39-1.el6.x86_64.rpm 

[[email protected] mysql]# rpm -ivh MySQL-shared-5.6.39-1.el6.x86_64.rpm 

7. mysql5.6数据库会自动生成随机密码, 通过安装的日志查询到密码在 /root/.mysql_secret  文件里

.centos6.5安装mysql5.6

8. 复制生成的随机密码

[[email protected] ~]# cat .mysql_secret 
# The random password set for the root user at Sat Sep 15 11:25:09 2018 (local time): 0NHZ5NAnEpBNDBBT

9.启动mysql 

[[email protected] ~]# service mysql start

10.第一次密码就使用刚拷贝.mysql_secret文件里的随机密码:0NHZ5NAnEpBNDBBT

[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.39

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

11.设置密码

mysql> set password = password('123456');

Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

12.添加服务 和开机自启

[[email protected] ~]# chkconfig --add mysql
[[email protected] ~]# chkconfig mysql on

13. 这时候通过navicat 链接数据库还是链接不了 ,进入mysql设置连接用户

mysql> grant all privileges on *.* to 'root' @'%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

14.开放系统端口

[[email protected] ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[[email protected] ~]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

完成 !

 

相关文章: