MySQL installation under Linux such as Alibaba Cloud and Tencent Cloud (including remote connection and other settings)

First put a SQLyogEnt program to facilitate connection after installation:

链接:https://pan.baidu.com/s/1O7kpbapqvgQbV33g7Vfj8w 
提取码:icsu 

1. First download the mysql installation package:
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

2. If an error is reported: -bash: wget: command not found,
indicating that the wget tool is not installed on the server, we first install wget
yum -y install wget

3.安装mysql
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm

4. Install the mysql server online
yum -y install mysql-community-server
downloads more things and you have to wait a while

5. Start the mysql service
systemctl start mysqld

6. Set mysql to start at boot;
systemctl enable mysqld

systemctl daemon-reload

7. Modify the root local login password (find the temporary password of the root user first, log in to the MySQL service, and then execute the modification command) After
mysql is installed, a temporary default password is generated for root in the /var/log/mysqld.log file

vi /var/log/mysqld.log

Find this line: 2019-09-15T08:19:41.074255Z 1 [Note] A temporary password is generated for root@localhost: m4sot1K>%k,

The temporary password here is: m4sot1K>%k,

mysql -u root -p

Enter the temporary password to enter the mysql command line

ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘@Jsbsyl123’;

Modify the password as: @Jsbsyl123 (Note that the default password policy of mysql5.7 requires that the password must be a combination of uppercase and lowercase alphanumeric special letters, at least 8 digits)

8. Set to allow remote login
Mysql does not allow remote login by default, we need to set

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘@Jsbsyl123’ WITH GRANT OPTION;

Then exit:
exit

9. Let the firewall open port 3306 ()
firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload

In addition, Alibaba Cloud and Tencent Cloud need to go to the console to set up security groups and open ports

10. Configure the default encoding as utf8 and
modify the /etc/my.cnf configuration file

vi /etc/my.cnf

Add encoding configuration under [mysqld], as shown below:
character_set_server=utf8

init_connect=‘SET NAMES utf8’

11. Restart the mysql service

systemctl restart mysqld

12.Check the code:
mysql -u root -p

show variables like ‘%character%’;

13. Test, use SQLyogEnt to connect remotely

Note: If it fails, find the reason step by step, such as
1. Check whether the MySQL service on Linux is started:

netstat -ntlp

See if there is port
3306. 2. Window can ping the port of MySQL service under LInux.
Window enter the dos command:

telnet ip(Linux的IP) 3306

If the window prompts that there is no such command, it means that the Telnet command is not enabled in the window, check it yourself

Guess you like

Origin blog.csdn.net/NicolasLearner/article/details/112330072