These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' on the new forum.
Hi when I run this command from ssh via root it doesn't work. How do I get it to work without using the password? On my other servers it's possible to run this command and it just works.
[root@- www]# mysqldump db > file.sql mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect
BTW, i'm running centos 6.2 64bit in root via command prompt ssh in latest vmin/wmin
Howdy,
You'd just need to add in a -p parameter, so that it'll prompt you for a password. You can do that like this:
mysqldump -p db > file.sql
ok, but on other servers no password is required since I'm already logged in as root it trumps all passwords normally. This is for an sh script so how would I get it so no password is prompted and it just dumps it without interuption.
also, what's the >
MySQL would always require you to enter a password, if there is one set for the user you're accessing.
The root user would indeed not require you to enter a password when accessing other user accounts on the server, but that's different from accessing MySQL-based accounts.
Regarding the ">" in your command -- that redirects the output of the mysqldump command into a file, rather than having it all display on the screen.
-Eric
Hi, You can store your root password in a local user version of .my.cnf which is read by the mysql commandline tools. More info:
Once mysql-server is installed it is ready for immediate use. However, it is best to at least set an admin password with:
$ /usr/bin/mysqladmin -u root password 'new-password'
You will then also need to let cron jobs work on the database so create a personal mysql config file for root in /root/.my.cnf containing:
[mysqladmin] user = root password =
Make sure the permissions are set appropriately:
# chmod 0600 /root/.my.cnf # ls -l /root/.my.cnf 4.0k -rw------- 1 root root 64 Oct 12 10:52 /root/.my.cnf
Best Wishes
Mark Fleeson
i have this problem too!
in my old server (with cPanel/WHM) i use a shell backup script that execute this command:
mysqldump -u root DB_NAME > BACKUP_PATH.sql
in my new server (that use virtualmin), the command accrues an error:
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect
it not seems safe to put root password (or password of any user that have full access to database) in simple backup.sh file! isn't it?!
(i also use the `mfleeson` note but the problem not solved.)
thanks to
mfleeson
note. i use#
sign in password and this cause problem in.my.cnf
file.