Mysql configuration on Ali cloud (CentOS)

First, log into Ali cloud, remote connections, here I am using Xshell 6 for connection.

See https://blog.csdn.net/lydia88/article/details/86006736

1, install mysql database

  Mysql download source installation package: wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

 

 

 

 2 mysql installation Source: yum localinstall mysql57-community-release-el7-8.noarch.rpm

  The middle will pop up an option to directly select y, if the end appeared complete !, then the source MySQL installation is complete

     

 

 

 3, testing whether the installation is complete: yum repolist enabled | grep "mysql * - community *.."

 

 

4, installation mysql: yum install mysql-community-server

    If you appear at the end Complete !, MySQL installation is complete

    

 

5, set to open start mysql service: systemctl enable mysqld

 

 

    

 

6, see the installation of mysql version: rpm -aq | grep -i mysql

 

     

 

7、systemctl restart mysqld

 

    

 

8, see the MySQL initial password: grep 'A temporary password' /var/log/mysqld.log

 

 

 

9, to change MySQL password: mysqladmin -u root -p 'old password' password 'new password'

 

 

 

 

 

Change the password problem here, change failed because the password is too simple reason. There are then two solutions:
    Method One: the password more complex (this is the most direct way)
    Method two: Close mysql password strength verified (validate_password)
        编辑配置文件:vim /etc/my.cnf, 增加这么一行validate_password=off
        编辑后重启mysql服务:systemctl restart mysqld

我使用的是方法二:

 

 

 

10、然后采用刚才的方法重新进行修改:(这里我擦除了密码)

 

 

 11、设置mysql能够远程访问:

    登录进MySQL:mysql -uroot -p,然后输入密码

增加一个用户给予访问权限:grant all privileges on *.* to '用户名'@'ip地址' identified by '密码' with grant option;  //可将ip改为%%,表示开启所有的

 

 

 

 

 

12、配置阿里云服务器,在自己的云服务器上添加一个安全组规则

      

 

 13、然后就可以在自己的电脑用工具中进行连接了

 

Guess you like

Origin www.cnblogs.com/minblog/p/11613979.html