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 can mysql be accessed by public network?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how mysql allows access to the foreign network, the article is very detailed, has a certain reference value, interested friends must read it!

Mysql allows public network access: first, modify the configuration file of mysql and add relevant code to the configuration file; then restart the mysql service and execute [service mysql restart]; finally, create a host and authorize users.

Mysql allows access to the public network:

1. Set the MySQL service to allow access to the public network

Modify the configuration files of mysql, either my.ini (windows) or my.cnf (linux)

Add to the configuration file

[mysqld] port=3306bind-address=0.0.0.0

Then restart the mysql service and execute service mysql restart.

2. Set mysql users to support public network access

You need to log in to mysql with root permission, update the mysql.user table, and set the Host field for the specified user to%. The default is 127.0.0.1 or localhost.

1. Log into the database

Mysql-u root-p

Enter password

Mysql > use mysql

two。 Query host

Mysql > select user,host from user

3. Create host

If there is no host value of "%", execute the following two sentences:

Mysql > update user set host='%' where user='root';mysql > flush privileges

4. Authorized user

(1) any host connects to the mysql server with user root and password mypwd

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' mypwd' WITH GRANT OPTION;mysql > flush privileges

(2) the host with IP 192.168.133.128 connects to the mysql server with user myuser and password mypwd

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'myuser'@'192.168.133.128' IDENTIFIED BY' mypwd' WITH GRANT OPTION; mysql > flush privileges; above is all the content about how mysql allows access to the public network. Thank you for reading! Hope to share the content to help you, more related 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

Database

Wechat

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

12
Report