1.mysqldump执行时Got error: 1045: Access denied for user  'root'@'localhost' (using password: YES) when trying to connect

解决办法

登录mysql客户端

mysql -hserverip -uroot -p

mysql> use mysql;
Database changed

mysql> update user set password=password('new password') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

 

 

 

2.
C:\Documents and Settings\Administrator>mysqldump   -u root -h 174.139.141.170 -
-port 3306   -ppa@170  --opt   pa0918|mysql   -u root   -pmysql   -C   pa0918
mysqldump: Got error: 1045: Access denied for user 'root'@'183.37.196.40' (using
 password: YES) when trying to connect

 

解决办法:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected