Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS7.2 how to install MySql5.7 and turn on remote connection authorization

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "CentOS7.2 installs MySql5.7 and opens remote connection authorization". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Install mysql5.7

The default source of yum after centos 7 uses mariadb to replace the original mysql, so there are some changes to the installation method:

Download the source of mysql

Wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

Install the Yum library

Yum localinstall-y mysql57-community-release-el7-7.noarch.rpm

Install mysql

Yum install-y mysql-community-server

Start the mysql service

Systemctl start mysqld.service

2. Modify the root password of mysql

Mysql5.7 enhances the security of root users, so a random password is initialized after the first installation. Here is how to view the initial random password

Grep 'temporary password' / var/log/mysqld.log

The results are as follows:

Enter mysql

Mysql-uroot-p

Modify the password

Set password = password ('yybrhr_2018'); alter user' root'@'localhost' password expire never;flush privileges

Then you can log in with the new password after you exit.

3. Remote connection authorization:

Grant all privileges on *. * to 'root'@'%' identified by' yybrhr_2018' with grant option

After authorization, use nevicat to check if you can connect, if not, it may be restricted by the firewall. The rule of opening database port needs to be added to the firewall.

4. The firewall opens the database port (default is 3306, which can be modified in / etc/my.cnf)

[1] View the current firewall

Firewall-cmd-list-all

[2] Open port 3306

Firewall-cmd-permanent-add-port=3306/tcp

[3] restart the firewall

Service firewalld restart

[4] check whether port 3306 is open

Firewall-cmd-query-port=3306/tcp

[5] check the current firewall again

Firewall-cmd-list-all

[6] Test again if you can connect remotely

This is the end of the content of "how to install MySql5.7 and turn on remote connection authorization in CentOS7.2". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report