阿里云Centos7.2安装MySQL

安装可用的rpm包

[root]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

查看可用安装资源

[root]# yum repolist enabled | grep "mysql.*-community.*"

安装

[root]# yum -y install mysql-community-server

配置

开启启动

[root]# systemctl enable mysqld

启动MySQL服务

[root]# systemctl start mysqld

设置密码

[root]# mysql_secure_installation

设置密码的过程中,有一些需要注意的点如下所示:

1、Set root password? [Y/n] y        [设置root用户密码]
2、Remove anonymous users? [Y/n] y            [删除匿名用户]
3、Disallow root login remotely? [Y/n] n            [禁止root远程登录]
4、Remove test database and access to it? [Y/n] y       [删除test数据库]
5、Reload privilege tables now? [Y/n] y        [刷新权限]

远程客户端访问

[root]# mysql -uroot -p       [首次无密码,直接回车]
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;