简体   繁体   中英

_mysql_exceptions.OperationalError: 1045, "Access denied for user

I want to connect to my database from Python shell

import MySQLdb
db = MySQLdb.connect(host="localhost",user="milenko",passwd="********",db="classicmodels")

But

 File "/home/milenko/anaconda3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'milenko'@'localhost' (using password: YES)")

I have created user

 CREATE USER 'milenko'@'localhost' IDENTIFIED BY '8888888';

but still the problem is still there. Databases

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ap1                |
| classicmodels      |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

What does this mean?How to resolve this problem?

this generally means you do not have permissions to access the server from that particular machine. to fix it, either create user 'milenko'@'localhost' or 'milenko'@'%' using your root server user

OR

grant your user privileges on that particular db

确保您的本地服务器(例如WampServer)已打开。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM