Python如何连接旧密码模式的MySQL
闲来无事想写个脚本获取MySQL的数据,然后发现无论用Python的pymysql还是MySQL库都是无法成功连接上MySQL5.1版本,提示
raise get_mysql_exception(
mysql.connector.errors.DatabaseError: 2027 (HY000): Malformed packet
或者
received unknown auth switch request
然而使用第三方软件是正常连接。

查阅了很多资料,最终在pymysql的GitHub上找到解决办法,https://github.com/PyMySQL/PyMySQL/issues/981
解决办法也很简单,pymysql==0.10.1就正常连接了
UserWarning: old password (for MySQL <4.1) is used.  Upgrade your password with newer auth method.
old password support will be removed in future PyMySQL version
  warnings.warn("old password (for MySQL <4.1) is used.  Upgrade your password with newer auth method.\n"
连接成功!
MySQL 版本:5.1.73-log
正常情况下MySQL早期版本采用的是古老的密码认证方式,这种方式很容易遭受攻击。因此,MySQL 4.1版本引入了新的密码认证方式。因此这是一个古老坟贴了。
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号