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.
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
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!