CentOS 8 install MySQL 8.0 and configure remote login
1. Install MySQL Install MySQL
using the latest package manager
sudo dnf install @mysql
Startup#After the
installation is complete, run the following command to start the MySQL service and make it start automatically at startup:
sudo systemctl enable --now mysqld
To check whether the MySQL server is running, enter:
sudo systemctl status mysqld
Add password and security settings#
Run the mysql_secure_installation script, which performs some security-related operations and sets the MySQL root password:
sudo mysql_secure_installation
Proceed as follows:
- You are required to configure the VALIDATE PASSWORD component: Enter y and press Enter to enter the configuration
- Select the password verification strategy level, I choose 0 (low) here, press Enter to enter the new password twice
- Confirm whether to continue using the provided password? Type y and press enter
- Remove anonymous users? Type y and press enter
- Do not allow root remote login? I need to log in remotely, so enter n and press Enter
- Remove the test database? Type y and press enter
- Reload the permission table? Enter y and press Enter to
configure remote login#
If you need to set up root account remote login, in the previous step, root remote login is not allowed? This step needs to be set to n.
Next, log in to MySQL locally, and set the host field of the root user to'%', which means to accept login requests from all IP addresses of root:
Log in to MySQL locally:
mysql -uroot -p上面步骤中设置的密码
After you press Enter, you can log in, and then the terminal becomes mysql> beginning:
Then continue to execute the mysql statement, and set the host field of the root user to'%':
use mysql;
update user set host='%' where user='root';
flush privileges;
After the setting is complete, enter exit to exit mysql and return to the terminal shell interface.
Then open the 3306 port of the system firewall, which can be configured in the Alibaba Cloud server security group:
Network Security-"Security Group" Configuration Rules-"Add Security Group
Restart Service#
sudo systemctl restart mysqld
Next you can test the connection:
Succeeded!