Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql Python connect

I'm trying to connect python with MySQL, but I get this error:

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

I'm trying to solve it for 6 hours and I fail. Can any one please help me ?

like image 230
Joja Ingy Avatar asked Feb 03 '26 21:02

Joja Ingy


1 Answers

it means that you forgot the password parameter, which in mysql is not required.

from a unix command line:

$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$ mysql -u root -p
Enter password: 
<typing password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.1.37-1ubuntu5.5 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

not exactly the same as logging from python,

but it's the same error, and most likely means that in your case the password argument did not make it to mysql at all.

when I type the wrong password I get a very different error on the command line:

$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
like image 112
Fire Crow Avatar answered Feb 05 '26 12:02

Fire Crow