mysql5.7本地用户无法使用密码登录

mysql5.7本地用户无法使用密码登录

在安装mysql5.7,创建普通用户@localhost并在本地使用pyspider进行登陆时,出现access denied,问题的原因是:

1、新版的mysql(5.7)本地登录时默认使用socket登录,即便指定账户,但并不对密码进行判定;

2、创建的localhost普通用户可以手动登录,但无法使用pyspider登录。

因此,考虑到以上情况,解决的办法是绕过localhost的socket登录,并尽可能不改动mysql的设计。

解决步骤:

1、使用root登录mysql

2、创建用户并授权给127.0.0.1和%

3、使用创建的用户和密码进行登录(此时绕过socket)

备注:需要注意的是,localhost和%是不兼容的,即前者负责本地登录,后者负责除本地外的其它ip登录,而127.0.0.1使用tcp登录(而不是socket)

4、修改该用户的密码

update mysql.user set authentication_string=password('123123') where user='spider' and Host='localhost';

上一篇
下一篇