>  기사  >  데이터 베이스  >  mysql远程连接可以,本地连接报错_MySQL

mysql远程连接可以,本地连接报错_MySQL

WBOY
WBOY원래의
2016-06-01 13:06:091424검색

使用python的MySQLdb库连接本地的mysql数据库,报错如下:

File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'***-vuldb.local' (using password: YES)")

/

解决方法:

添加'root'@'***-vuldb.local'的访问权限

授权root用户拥有testDB数据库的所有权限(某个数据库的所有权限):

   mysql>grant all privileges on testDB.* to root@***-vuldb.localhost identified by '1234';

  mysql>flush privileges;//刷新系统权限表

  格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"; 

参考:http://www.cnblogs.com/fly1988happy/archive/2011/12/15/2288554.html

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.