Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:47:15
Original
1340 people have browsed it

使用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

使用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)")


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


解决方法:

添加'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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!