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 machine
MySQL
Is started, then open terminal, enter the following command to connect toMySQL
, need to enter the machineMySQL
The 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 in
mysql
Database, so usemysql
The database.
use mysql
Copy the code
- Enter the following command to change the remote connection Settings, previously
root
Indicates that someone accesses the local computerMySQL
The user name afterroot
Indicates that someone accesses the local computerMySQL
The 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 appears
host = %
,user = root
The 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.