Fastcloud’s Blog


mysql -h localhost -u root -p myrootpassword produces “access denied” (or similar) errors

If the following command doesn’t work for you
mysql -h localhost -u root -p myrootpassword
and produces errors like:
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
or
ERROR 1049 (42000): Unknown database 'myrootpassword '
try the following command:
mysql -h localhost -u root -p Note: NO password is passed to the -p parameter!
You’ll be prompted for your password -> Enter it.

You could also try:
mysql -h localhost -u root --password="myrootpassword"

How to execute sql-script with the mysql console?
If you want to execute a *.sql-file you might try the following command:
mysql -h localhost -u root --password="myrootpassword" --database="mydb" < /path/to/my/sqlfile.sql -- Note: single line!

Comments Off