Forums

ERROR 1045 (28000)

Hi - I made some mysql databases a heck of a long time ago and today decided to revisit using mysql. I couldn't remember the password so I changed it through the MySQL settings page. However, I am unable to log in to mysql through bash (or my django app).

04:48 ~ $ mysql -h <myusername>.mysql.pythonanywhere-services.com -u <myusername> <myusername>$mysitedb -p
Enter password: 
ERROR 1045 (28000): Access denied for user '<myusername>'@'10.0.0.55' (using password: YES)

Is there something obvious that I'm missing?

The problem from Bash consoles is that you're specifying the database name without putting single quotes around it, so it's interpreting $mysitedb as an environment variable and trying to connect to a database called myusername. Try running

04:48 ~ $ mysql -h <myusername>.mysql.pythonanywhere-services.com -u <myusername> '<myusername>$mysitedb' -p

...and see if that works. Once we can get that working, then hopefully the issue on the Django side will become clear.

Oh sorry - I posted a poor example. In fact, I tried various combinations, including using single quotes. For good measure, I've tried again and still no luck. Also, I tried to find the user properties through the MySQL console and got an error as well:

SELECT USER FROM mysql.user -> ; ERROR 1142 (42000): SELECT command denied to user 'brucerollerson'@'10.0.0.96' for table 'user'

I'm not sure if I should or shouldn't have permissions to be able to do that.

You don't have permissions to access the users table, so that side of things is normal. But the command-line problem is definitely weird. Maybe you're just using the wrong password? When you click a link on the "Databases" page to start a MySQL console, it will use the password in the file .my.cnf in your home directory, so maybe check that and see if it's what you expect it to be?

That's fixed it, thanks! Strangely, I changed the password via the Databases page but that didn't update the my.cnf file. At least I know where to go to change it now, though.

That's still actually kind of weird. When you change your password from the "Databases" page, it updates it on the server and then writes the new password to .my.cnf. If you only change it in .my.cnf, then the one on the database server won't match the one in .my.cnf, so (for example) the MySQL consoles you launch from the "Databases" page won't work.

All I can imagine is that when you changed it from the "Databases" page originally, something went wrong and it wasn't changed at all in either place. I'm guessing you didn't see any errors, though, or you would have mentioned it earlier.

Either way -- the "Databases" page is definitely the right place to change your MySQL password.

Okay - I've just been playing with that and realised I hadn't been seeing the error that my new passwords were not secure enough. All problems are now solved. Thanks for your help!

Ah, that would explain it! Glad we were able to get to the bottom of it.

Hola, ayer estuve utilizando la consola de base de datos MYSQL y me funcionaba de lo más normal, con el tema de la creación de tablas, etc. Sim embargo, ahora me sale este error No connection. Trying to reconnect... ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ERROR: Can't connect to the server. Podría ayudarme por favor ?

@EduardoTG -- please have a look at this help page, it looks like you configured the db connection improperly.