Home  >  Article  >  Database  >  How to connect remotely to MySQL

How to connect remotely to MySQL

(*-*)浩
(*-*)浩Original
2019-05-06 17:00:1835166browse

By default, mysql only allows local login. If you want to enable remote connections, you need to modify the /etc/mysql/my.conf file.

Recommended courses: MySQL Tutorial.

How to connect remotely to MySQL

MySQL remote connection method:

The first step is to modify /etc/mysql/my.conf

Find the line bind-address = 127.0.0.1 and change it to bind-address = 0.0.0.0

The second step is to grant permissions to users who need to log in remotely.

1. Create a new user to remotely connect to the mysql database

grant all on *.* to admin@'%' identified by '123456' with grant option;
flush privileges; Allow computers with any IP address (% means allow any IP address) to access this mysql server with the admin account and password (123456). Note that the admin account does not necessarily exist.

2. Support root user to allow remote connection to mysql database

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;flush privileges;

The third step is to view the system users

How to connect remotely to MySQL

The above is the detailed content of How to connect remotely to MySQL. 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