简体   繁体   中英

how to pass password in mysql command line

I've a password with special characters in it, something like this eu8y~!~LZVdzW!2A .

Whenever, I try to fire the mysqldump command, it throws an error saying

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

this is how I do it.

mysqldump -uroot -p'eu8y~!~LZVdzW!2A' db_name > db.sql

however, if provide the password separately, it works.

mysqldump -uroot -p db_name > db.sql

I run the above command in python. How can I do it?

I can't reproduce the problem:

mysql> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'eu8y~!~LZVdzW!2A';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON `db_name`.* TO 'myuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
$ mysqldump -umyuser -p'eu8y~!~LZVdzW!2A' db_name > db.sql

The file ( db.sql ) is generated as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM