[root@localhost ~]# python

Python 2.7.5 (default, Apr 11 2018, 07:36:10)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import MySQLdb

>>> db = MySQLdb.connect(host='127.0.0.1',user='root',passwd='xukeng',db='real_name',charset='utf8')

>>> cursor = db.cursor()

>>> cursor.execute('select * from test limit 2')

2L

>>> db = MySQLdb.connect(host='192.168.0.50',user='root',passwd='xukeng',db='real_name',charset='utf8')

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "/usr/lib64/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect

return Connection(*args, **kwargs)

File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__

super(Connection, self).__init__(*args, **kwargs2)

_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'192.168.0.50' (using password: YES)")

------------

看不明白为什么换了一个HOST地址就登入不了,都是在本机。接着忽然想到是不是数据库的用户权限限制了。

接着登入数据库查看

MariaDB [real_name]> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> select user,host from user;

+-----------+-----------------------+

| user      | host                  |

+-----------+-----------------------+

| newdbuser | %                     |

| root      | 127.0.0.1             |

| root      | ::1                   |

| root      | localhost             |

| root      | localhost.localdomain |

+-----------+-----------------------+

5 rows in set (0.00 sec)

果然,ROOT用户没有外网登入的权限

换了一个用户 NEWDBUSER

>>> db = MySQLdb.connect(host='192.168.0.50',user='newdbuser',passwd='db123456',db='real_name',charset='utf8')

>>>

OK,没问题

python连接mariadb报错解决1045, "Access denied for user 'root'@'192.168.0.50' (using password: YES)的更多相关文章

  1. idea启动报错:Access denied for user 'root '@'192.168.100.XXX' (using password: YES)

    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wit ...

  2. 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)

    一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...

  3. phpadmin登录报错:#1045 - Access denied for user 'root'@'localhost' (using password: yes)

    原因:phpmyadmin无法通过root+密码联系mysql; 解决方法:重置mysql密码. 步骤: 1.cmd 2.登录MySQL:mysql -uroot -p    ->root是用户 ...

  4. 解决MySql Access denied for user 'root'@'192.168.1.119' to databse 的问题

    因为ip未授权,在navicat中执行 grant all privileges on *.* to 'root'@'192.168.1.119' identified by 'root' with ...

  5. java.sql.SQLException: Access denied for user 'root'@'10.1.0.2' (using password: YES)

    java.sql.SQLException: Access denied for user 'root'@'10.1.0.2' (using password: YES) at com.mysql.c ...

  6. 如何解决#1045 - Access denied for user 'root'@'localhost' (using password: NO)问题

    1. #1045 - Access denied for user 'root'@'localhost'  (using password: NO) 解决方案 在phpMyAdmin中librarie ...

  7. mysql 远程连接 1045 Access denied for user 'root'@'XX.XX.XX.XX' (using password:YES)

    用户名/密码错误,需要输入开放远程时设置的密码

  8. #1045 - Access denied for user 'root'@'localhost' (using password: NO)的问题

    问题描述:  修改了root的密码,然后在http://localhost/phpmyadmin下无法登录了  报错:#1045 - Access denied for user 'root'@'lo ...

  9. Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YES)报错

    MySQL 连接错误,使用Navicat连接MySQL出现错误:1045 Access denied for user 'root'@'localhost' (using password: YES) ...

随机推荐

  1. Internet History, Technology, and Security(week9)——Web Security

    Secure Web Connections: Security Public/Private Key - Secure Sockets 凯撒密码容易被破解,后来人们发明了公钥和私钥,由于私钥一定是要 ...

  2. 使用vue技术应当使用的技术和兼容性选择

    假如你的前端框架使用了vue,那你可以大胆地使用以下技术,并忽略其他js和css的兼容性问题,因为 关于vue的兼容性 官方给出了规定 Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 ...

  3. Extending Widgets with the Widget Factory

    https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/ 实例 https://github.com/tkvw/jQue ...

  4. wowza 降低延迟

    转自:http://www.ttstream.com/wowza/live/howToAchieveTheLowestLatencyFromCaptureToPlayback   这篇文章介绍了在用R ...

  5. 高通Camera驱动分析【转】

    本文转载自:http://blog.csdn.net/liwei16611/article/details/53955711 1.Sensor slave配置 结构体msm_camera_sensor ...

  6. hyperworks2019x中模型简化

    Defeature→Fillets

  7. fedora如何使用themes主题?

    DBus: 是一个 local 的IPC 进程间通信机制 如果是(一对一) 多对多的通信, 则DBUS 后台充当了一个路由器的角色. ibus: 是包含: python gtk dbus的 scim- ...

  8. 【C++】fill函数,fill与memset函数的区别

    转载自:https://blog.csdn.net/liuchuo/article/details/52296646 memset函数 按照字节填充某字符在头文件<cstring>里面fi ...

  9. 20160711--C# 委托的三种调用示例(同步调用 异步调用 异步回调)【转载】

    首先,通过代码定义一个委托和下面三个示例将要调用的方法: 代码如下: public delegate int AddHandler(int a,int b); public class 加法类 { p ...

  10. 003-CHROME开发者工具的小技巧

    首先调试先进入到调试模式,快键键F12 1.代码格式化 有很多css/js的代码都会被 minify 掉,你可以点击代码窗口左下角的那个 { }  标签,chrome会帮你给格式化掉. 2.强制DOM ...