Get the App
SLTechnology News&Howtos  ›  Database  › 

How can mysql be accessed by public network?

Shulou Source: shulou.com Published: 2022-06-01 02:44:01 09月30日 Update

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!

Tags: Users services files configurations passwords there are hosts content methods servers logins codes values interests fields guys partners data databases more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Shulou Technology Shulou Tech Info Apple