The project goes live on Alibaba Cloud (3) Install mysql8 on the cloud (based on the ubuntu system)

Install mysql 8. 

1. Install mysql8 server via apt

sudo apt-get install mysql-server

2. Log in to mysql, there is no password at this time, log in directly, then set the password, and set to allow remote login. 

mysql -uroot -p

Just press Enter, no password. 

3. For security, first set the password of the root user to be more complicated, and then create a new user to access the database. 

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'a';

The above setting method shows that root can only log in locally on localhost, and the login password is a. (Please set it more complicated)

3. Because the encryption method of mysql8 is different, mysql8 cannot set its own permissions, and it is necessary to create a new user

create user a@'%' identified by 'a';
grant all on *.* to a@'%';
ALTER USER 'a'@'%' IDENTIFIED WITH mysql_native_password BY 'a';
flush privileges;

4. Open remote access permissions (authorize remote connections)

   Exit mysql first

exit

   Then modify the content of the /etc/mysql/mysql.conf.d/mysqld.cnf file to open the remote access permissions. 

vi /etc/mysql/mysql.conf.d/mysqld.cnf

 

After entering the file, press the i key to enter the editing mode, find the following sentence, and enter a # in front     

Comment out bind-address = 127.0.0.1, this sentence means to bind local access.

Press the ESC key to exit the editing mode, enter :wq which means exit and save the changes. 

5. Restart mysql. 

/etc/init.d/mysql restart

6. Test login as root in the server.    

mysql -uroot -pa

 7. Use Navicat to test remote login locally. 

     The test is ok. Finally, the password of the online system must be set more complicated and safety first. 

Guess you like

Origin blog.csdn.net/zhangyingchengqi/article/details/108773348
Recommended