mysqldump access denied

早过忘川 提交于 2019-12-18 01:29:39

问题


When I try to backup using mysqldump from ssh, I run the following command on machine 10.64.1.1. It gives the following error.

mysqldump --user=test -p=password --host=10.64.1.2 --tab=. databasename tablename

mysqldump: Got error: 1045: Access denied for user 'test'@'10.64.1.1' (using password: YES) when trying to connect

However, I can access mysql using the same user and password.

mysql --user=test -p[password]

Current user: test@10.64.1.1

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter: ;

Server version: 5.0.91-50-log Percona SQL Server, Revision 73 (GPL)

Protocol version: 10

Connection: 10.64.1.2 via TCP/IP

Updates:

If I do following mysql document: --password[=password] or -p[password].

Since my password contains special symbol @, Mysql cannot detect user correctly. It complains:

mysqldump: Got error: 1044: Access denied for user 'test'@'%' to database


回答1:


I think that you would have to lose the = when using -p or do it with --password :

--password[=password], -p[password]

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, you are prompted for one. Specifying a password on the command line should be considered insecure. See Section 6.6, "Keeping Your Password Secure".




回答2:


You have to run CMD.EXE as the Administrator:

Right click on cmd.exe --> Run as Administrator and then type your command:

mysqldump -u[username] -p[password] -h[ip or name] yourdatabasename > c:\sqlfile.sql

It should work fine.




回答3:


I know the topic is very old, but I happened to have the same issue. I figured out that the problem was just the special character used in the password. In fact they must be escaped with the anti slash: --password=123\@456 or using signle quotes --password='123@456'




回答4:


I had the same problem with a DB user created via Plesk. The user has permissions for a single database. If I specify the database name I get the error mentioned above. If I specify -A for all databases, the dump works.




回答5:


In windows, I resolved it by making a directory and then dumping *.sql file in backup directory.

C:\backup

There are no issues with commands :
Remove the [ ] square brackets

mysqldump -u[username] -p[password] -h[ip] yourdb > C:\backup\sqlfile.sql

It worked for me:)




回答6:


One more possible cause can be the place you are trying to create dump. Writing mysqldump -u[username] -p yourdb > D:\backup\sqlfile.sql instead of mysqldump -u[username] -p yourdb > sqlfile.sql resolved my problem.




回答7:


There is no = (equal sign) for the connection options. You want the following.

mysqldump -u test -ppassword -h 10.64.1.2 ...

Check out the docs for more details on the other options.




回答8:


Heres what worked for me- run cmd line as admin. dont put any password after -p, you are automatically prompted to enter a password and it works.




回答9:


Trying with this command

mysqldump --user=root -p --host=127.0.0.1 --databases database_name [database_name_2,...] > dump.sql


来源:https://stackoverflow.com/questions/5767036/mysqldump-access-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!