In my daily work, I often encounter that the MySQL database is stored on someone’s computer, and other people need to connect to the MySQL database on that person’s computer by IP address. However, in order to connect to the MySQL database on that person’s computer, the MySQL on that person’s computer must be enabled remote connection. MySQL > enable remote connection


MySQL Enabled the remote connection

  • First make sure the machineMySQLIs started, then open terminal, enter the following command to connect toMySQL, need to enter the machineMySQLThe connection password of.
/usr/local/mysql/bin/mysql -u root -p
Copy the code

  • Enter the following command to select the database you want to use, modify the basic remote connection information, and save it inmysqlDatabase, so usemysqlThe database.
use mysql
Copy the code

  • Enter the following command to change the remote connection Settings, previouslyrootIndicates that someone accesses the local computerMySQLThe user name afterrootIndicates that someone accesses the local computerMySQLThe password.
GRANT ALL PRIVILEGES ON *.* TO 'root'@The '%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Copy the code

  • Type the following command to refresh the permissions you just changed for them to take effect.
flush privileges;
Copy the code

  • Enter the following command to see if the modification is successful, if a line appearshost = %user = rootThe modification is successful.
select host,user from user;
Copy the code


MySQL remote connection is enabled, and other users can connect to the local MySQL database using the IP address.

In the future, you will be grateful for your hard work now, and wish you and your readers a better way of development.

My portal: blog, Book, Twitter, GitHub.