Linux centOS安装MySQL

Posted crazy_cat

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux centOS安装MySQL相关的知识,希望对你有一定的参考价值。


0、先将原先的mysql卸载

1、先将安装包放到/opt/software/mysql/下

2、解压

unzip mysql-connector-java-5.1.27.tar.gz

3、安装服务端

sudo rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm

4、安装客户端

sudo rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm

5、启动MySQL服务

sudo service mysql start

6、查看初始密码

sudo cat /root/.mysql_secret

7、使用初始密码登录MySQL

mysql -uroot -pykOCjZ0ML9KJd9qS

8、修改MySQL密码

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

9、退出MySQL,然后使用新密码重新登录

mysql> quit;
$ mysql -uroot -p123

10、修改root用户远程访问权限

? (1)使用mysql库

mysql> use mysql;

? (2)查看

mysql> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | hadoop106 |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)

? (3)把localhost改成%

mysql> update user set host='%' where host='localhost';   

? (4)再次查询

mysql> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | %         |
| root | 127.0.0.1 |
| root | ::1       |
| root | hadoop106 |
+------+-----------+
4 rows in set (0.00 sec)

? (5)把其他的用户删除

mysql> delete from user where host!='%';

? (6)刷新

mysql> flush privileges;

? (7)安装完成

mysql> quit;

以上是关于Linux centOS安装MySQL的主要内容,如果未能解决你的问题,请参考以下文章

linux(centos)上安装mysql教程

Linux(Centos)服务器安装MySQL 5.7

Linux centos 下在线安装mysql

在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7mysql)

Linux/CentOS下安装MySql RPM Bundle

Linux(CentOS)安装Mysql数据库