Portal Home > Knowledgebase > Articles Database > ERROR 1045 (28000): Access denied for user 'root'@'localhost'


ERROR 1045 (28000): Access denied for user 'root'@'localhost'




Posted by shareef83, 02-16-2013, 07:36 AM
Hi, i am trying to login to mysql and getting the below error. I am giving command D:\wamp\mysql\bin>mysql -u root pass ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N O) ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) I knwo the password is correct as i acn loging to database using sqlyog, i cannot reset the password as this is production, can someone kindly guide me what could be the problem

Posted by zoid, 02-16-2013, 08:57 AM
You need to specify the password with the -p parameter

Posted by LeaTrueman, 02-16-2013, 10:17 AM
The command should be like this, mysql -uroot -p

Posted by WebHostDog, 02-16-2013, 12:08 PM
also can add the MySQL root password under: /root/.my.cnf

Posted by shareef83, 02-17-2013, 02:55 AM
I am new to mysql, thank you all for your help. i was able to login after i gave -------------------- D:\wamp\mysql\bin>mysql -u root -p mysql_db Enter password: *********** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1093 to server version: 5.0.27-community-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> --------------------- But i again get access denied message when i try to take backup D:\wamp\mysql\bin>mysqldump -u Root -p pass mysql_db < E:\BACKUP_SCRIPTS\bac kupfiles Access is denied. ---- Also for fear of security breach i do not want ot update hte password in /root/.my.cnf

Posted by BreakFree, 02-17-2013, 02:58 AM
mysqldump --opt -Q -u dbusername -p databasename > E:\BACKUP_SCRIPTS\backupname.sql Try using that and replacing the dbusername, databasename, and the path to the backup file. This will prompt you for the password after the command is ran. So if you're using "root" as the user and "mysql_db" as the database name, it should look like: mysqldump --opt -Q -u root -p mysql_db > E:\BACKUP_SCRIPTS\backupname.sql You'll get a prompt to enter your password and it should perform the backup. You need to specify the entire file name. The above is missing the .sql at the end of the backup file name, so it fails. Last edited by BreakFree; 02-17-2013 at 03:01 AM.

Posted by shareef83, 02-17-2013, 03:17 AM
D:\wamp\mysql\bin>mysqldump --opt -Q -u Root -p information_schema> E:\BACKUP_SC RIPTS\bncuat_BKP.sql Enter password: *********** mysqldump: Got error: 1045: Access denied for user 'Root'@'localhost' (using pas sword: YES) when trying to connect

Posted by shareef83, 02-17-2013, 03:21 AM
thank you for quick reply NodeKi, i still get the message access denied, -------- D:\wamp\mysql\bin>mysqldump --opt -Q -u Root -p information_schema> E:\BACKUP_SC RIPTS\bncuat_BKP.sql Enter password: *********** mysqldump: Got error: 1045: Access denied for user 'Root'@'localhost' (using pas sword: YES) when trying to connect ---------- i actually have schedule a backup so the password should be command line, but i had tried scripts from google for scheduled backup, they were failing so i tried to take backup of 1 db and cehck and thsi is the error.

Posted by shareef83, 02-17-2013, 04:09 AM
thank you all backup is working now, uppercase 'R' in Root was the issue tried with root am able to take backup, but how can i specify password in the same line instead of an enter,now i am scheduling a batch file to take backup of all files, but below script goes into infinite loop and i have to stop the batch forcefully, --------------------- cd D:\wamp\mysql\bin set MYSQLUSER=root set MYSQLPASS=pass set BATCHFILE=E:\BACKUP_SCRIPTS\Batch_mysqldump.BAT set DUMPPATH=E:\BACKUP_SCRIPTS\backupfiles For /f "tokens=1-3 delims=/. " %%a in ('date /t') do (set curdate=%%c%%b%%a) For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set curtime=%%a%%b) mysql -u%MYSQLUSER% -p%MYSQLPASS% -AN -e"SELECT CONCAT('mysqldump -f -u%MYSQLUSER% -p%MYSQLPASS% --routines --triggers ',schema_name,' > %DUMPPATH%\%curdate%-%curtime%-',schema_name,'.sql') FROM information_schema.schemata WHERE schema_name NOT IN ('information_schema','performance_schema')" >> %BATCHFILE% start /wait /b %BATCHFILE ------------------



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read