问题描述:mysqldump在做备份时报错mysqldump: Got error: 1045: Access denied for user 'root'@'localhost',如下所示:
数据库:mysql 5.7.21
1、问题重现
[root@leo-mysql5721 ~]# mysqldump -uroot -p --tab=/tmp booksDB
Enter password:
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
2、解决方案
--在备份命令上添加加-hlocalhost.
[root@leo-mysql5721 ~]# mysqldump -uroot -p -hlocalhost --tab=/tmp booksDB
Enter password:
--如上所示,成功备份.
[root@leo-mysql5721 tmp]# ls -ltr
total 32
-rw-------. 1 root root 0 Jun 23 08:47 yum.log
drwxr-xr-x. 2 root root 18 Jun 23 08:49 hsperfdata_root
-rwx------. 1 root root 836 Jun 23 08:55 ks-script-8lHwuU
drwx------. 3 root root 17 Jun 23 08:56 systemd-private-796ca56c188942b08f0997022d3e8f17-vmtoolsd.service-cG7DC9
drwx------. 3 root root 17 Jun 23 08:56 systemd-private-796ca56c188942b08f0997022d3e8f17-rtkit-daemon.service-Xe3Eku
-rw-r--r--. 1 root root 0 Jun 23 08:56 storage.log
-rw-r--r--. 1 root root 0 Jun 23 08:56 program.log
-rw-r--r--. 1 root root 0 Jun 23 08:56 packaging.log
-rw-r--r--. 1 root root 0 Jun 23 08:56 sensitive-info.log
-rw-r--r--. 1 root root 0 Jun 23 08:56 ifcfg.log
drwx------. 3 root root 17 Jun 23 08:56 systemd-private-796ca56c188942b08f0997022d3e8f17-cups.service-Zxcwvz
-rw-r--r--. 1 root root 1283 Jun 23 08:56 anaconda.log
drwx------. 3 root root 17 Jun 23 08:56 systemd-private-796ca56c188942b08f0997022d3e8f17-colord.service-wZRrBT
drwx------. 2 liujun liujun 25 Jun 23 09:01 ssh-nGJMLEiC7fhz
drwx------. 2 liujun liujun 6 Jun 23 09:01 tracker-extract-files.1000
drwxr-xr-x. 2 liujun liujun 6 Jun 23 09:01 hsperfdata_liujun
-rw-r--r--. 1 root root 1576 Jun 24 23:08 authorbook.sql
-rw-rw-rw-. 1 mysql mysql 88 Jun 24 23:08 authorbook.txt
-rw-rw-rw-. 1 mysql mysql 135 Jun 24 23:08 authors.txt
-rw-r--r--. 1 root root 1408 Jun 24 23:08 authors.sql
-rw-rw-rw-. 1 mysql mysql 218 Jun 24 23:08 books.txt
-rw-r--r--. 1 root root 1387 Jun 24 23:08 books.sql
说明:authorbook.sql、authorbook.txt、authors.txt、authors.sql、books.txt、books.sql为备份文件.
参考网址:https://blog.csdn.net/m0_47219942/article/details/108164589
mysqldump在做备份时报错mysqldump: Got error: 1045: Access denied for user 'root'@'localhost'
原创Liujun_Deng 博主文章分类:Mysql ©著作权
文章标签 mysql mysqldump Got error: 1045 文章分类 MySQL 数据库
下一篇:mysqldump备份时报错mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv op
-
mysqldump: Got error: 1044: Access denied for user 'root'@'localhost'
出现如下错误:mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'test' when using LOCK TABLES添加--skip-lock-tables 参数后问题解决/usr/local/mysql/bin/mysqldump -uroot -p123456
mysql 数据库 information_schema single-transaction error: 1044