Home > Database > Mysql Tutorial > Detailed example of how to modify mysql to allow host access permissions

Detailed example of how to modify mysql to allow host access permissions

小云云
Release: 2017-12-25 14:20:19
Original
1649 people have browsed it

By default, mysql users do not have remote access permissions. Therefore, when the program and the database are not on the same server, we need to enable remote access permissions for mysql. Here, through this article, I will share with you how to modify the permissions that mysql allows host access. If you are interested, please take a look at the method. I hope it can help everyone.

Enable remote access permissions for mysql

By default, mysql users do not have remote access permissions, so when the program and the database are not on the same server, we need to enable remote access permissions for mysql .

There are two mainstream methods, the table modification method and the authorization method.

Relatively speaking, it is easier to change the table method, and I am personally more inclined to use this method. Therefore, only the table changing method is posted here

1. Log in to mysql

mysql -u root -p
Copy after login

2. Modify the user table of the mysql library and change the host item from localhost to %. %This means that any host is allowed to access. If only a certain IP is allowed to access, it can be changed to the corresponding IP. For example, localhost can be changed to 192.168.1.123, which means that only the IP 192.168.1.123 of the LAN is allowed to remotely access mysql. .

mysql> use mysql; 
mysql> update user set host = '%' where user = 'root'; 
mysql> select host, user from user; 
mysql> flush privileges;
Copy after login

Firewall opens port 3306

Related recommendations:

MySQL setting access permission examples detailed explanation

In Angularjs How to set page access permissions

Summary of methods to set remote access permissions for MySQL database

The above is the detailed content of Detailed example of how to modify mysql to allow host access permissions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template