1.新开的云服务器,需要检测系统是否自带安装mysql
# yum list installed | grep mysql
2.如果发现有系统自带mysql,果断这么干
# yum -y remove mysql-libs.x86_64
3.随便在你存放文件的目录下执行,这里解释一下,由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,还好mysql5.6只有79M大,而mysql5.7就有182M了,所以这是我不想安装mysql5.7的原因
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.接着执行这句,解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo
# rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.这个时候,可以用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件
#yum repolist all | grep mysql
6.安装mysql 服务器命令(一路yes):
# yum install mysql-community-server
7.安装成功后
# service mysqld start
8.进入mysql 并且修改密码
mysql> use mysql;
Database changed
mysql> update user set password=password('123') where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.38 MySQL Community Server (GPL)
9.设置远程访问
mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
[root@localhost ~]# service mysqld restart