This article mainly describes how to initialize the root password of MySQL and the correct operation steps to allow remote access and the actual application code, if you are interested in the actual operations that allow remote access to MySQL, the following articles will satisfy your curiosity.
MySQL has no password by default. Enter MySQL-u root to enter MySQL.
1. MySQL initializes the root password
Enter the MySQL database
- view sourceprint?1 mysql>update user set password=PASSWORD(‘123456’) where User='root';
2. To allow remote access to MySQL, you can use the following three methods:
A. Change the table.
- view sourceprint?1 MySQL -u root –p
- MySQL>use MySQL;
- MySQL>update user set host = '%' where user = 'root';
- MySQL>select host, user from user;
B. Authorization.
For example, you want the root user to use 123456 to connect to the MySQL server from any host.
- view sourceprint?1 mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
If you want to allow jack to connect to the mysql server from a host with ip address 10.10.50.127 and use 654321 as the password
- view sourceprint?1 mysql>GRANT ALL PRIVILEGES ON *.* TO 'jack'@’10.10.50.127’ IDENTIFIED BY '654321' WITH GRANT OPTION;
2 mysql> FLUSH RIVILEGES
C: run the following command on the machine where mysql is installed:
View sourceprint? 1 // enter the MySQL server
2 d: \ mysql \ bin \> mysql-h localhost-u root
3 // grant data access permissions to any host
4 mysql> grant all privileges on *. * TO 'root' @ '%' WITH GRANT OPTION
5 // make the modification take effect
6 mysql> FLUSH PRIVILEGES
7 // exit the MySQL server
8. mysql> EXIT
The above content describes how to initialize the root password for MySQL and allow remote access. I hope you will gain some benefits.
The above content describes how to initialize the root password for MySQL and allow remote access. I hope it will help you in this regard.