Home  >  Article  >  Database  >  How to Allow Remote Connections in MySQL for All Users?

How to Allow Remote Connections in MySQL for All Users?

Linda Hamilton
Linda HamiltonOriginal
2024-11-12 18:48:02382browse

How to Allow Remote Connections in MySQL for All Users?

Allowing Remote Connections in MySQL

When switching from SQL Server to MySQL, developers may encounter differences in granting remote access to databases. Unlike SQL Server's approach, MySQL requires manual execution of commands to permit remote connections.

To allow all remote connections remotely, as opposed to granting specific IP addresses, the following command can be utilized:

GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password'; 

Note that this command requires the creation of a corresponding user account on the localhost for the same user. Otherwise, MySQL's default anonymous account will take precedence due to its more specific host column value. Therefore, two accounts must be created:

GRANT ALL ON *.* to user@localhost IDENTIFIED BY 'password'; 
GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password'; 

Implementing this approach is suitable for development database environments that are only accessible within an internal network. It is crucial to exercise caution when permitting remote access to production databases.

The above is the detailed content of How to Allow Remote Connections in MySQL for All Users?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn