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

How CentOS7.2 installs MySql5.7 and turns on remote connection authorization

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install MySql5.7 and turn on remote connection authorization in CentOS7.2. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

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

The above is all the contents of the article "how to install MySql5.7 and turn on remote connection authorization in CentOS7.2". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report