MySQL default root user does not have password, enter mysql–u root to enter MySQL
1. Initialize root password
Go to MySQL Database
1 |
mysql> update user set password = PASSWORD (‘123456’) where User = ‘root‘ ; |
2, allow MySQL remote access, you can use the following three ways:
A, change the table.
1234 |
mysql-u root–p mysql>use MySQL; MYSQL> update user set host = where user = MYSQL> select host, user from user |
b, Authorization.
For example, you want to use root 123456 from any host to connect to the MySQL server.
1 |
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘ @ ‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION ; |
If you want to allow the user jack to connect to the MySQL server from the IP-10.10.50.127 host and use 654321 as the password
12 |
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘jack‘ @’10.10.50.127’ IDENTIFIED BY ‘654321‘ WITH GRANT OPTION ; mysql>FLUSH RIVILEGES |
C: Run on the machine where MySQL is installed:
12345678 |
//into MySQL server d:\mysql\bin\>mysql-h localhost-u root //give any host access to data Code class= "SQL Plain" >MYSQL> grant all privileges on *.* to ' root ' Code class= "SQL Plain" >@ '% ' with grant option //make the modification effective mysql>flush privileges //exiting the MySQL server mysql>exit |
MySQL initializes the root password and allows remote access