Database | remote access to Mysql appears Access denied for user 'root'@' solution

Phenomenon

The database remote access Mysql prompts an error:Access denied for user 'root'@' .....
insert image description here

reason

Error reason: The server cannot be connected without authorization to this ip

solve

  1. If you want root user name to use root password to connect to mysql server from any host.

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
    
    mysql>flush privileges;
    
  2. If you want to allow user root to connect to mysql server from host with ip 192.168.1.3 and use root as password

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'user'@'192.168.1.3' IDENTIFIED BY 'password' WITH GRANT OPTION;
    

    The above command creates a super account that can be logged in as root from any machine, and the password is root. In this way, you can use a convenient graphical tool (navicat for mysql) to log in and operate, including modifying the root password.

The username, password, and IP can be replaced with your own

Guess you like

Origin blog.csdn.net/u012294515/article/details/90078153