Remote connection MySQL error 1045 solution

MySQL remote operation steps:

Method 1:

USE mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Note: the password in the second step is the root login password you want to set. Note that it is not the root password during remote installation. What password you set here, then what is the remote login password
by analogy, other users can do the same
method 2: change the table method

mysql> use mysql; 
mysql> update user set host = '%' where user = 'root'; 
mysql> select host, user from user; 
mysql> flush privileges;

Read More: