mysql操作相关错误解决办法

1.执行mysql命令时出现:You must reset your password using ALTER USER statement before executing this statement.

  解决办法:

step 1: SET PASSWORD = PASSWORD('your new password');
step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
step 3: flush privileges;

2.Python连接mysql数据库出现错误:_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  解决办法:为创建的数据库赋予权限,参考mysql创建、删除用户

  为用户赋予数据库所有权限 

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

grant all privileges on my_test.* to root@localhost identified by '';
flush privileges;

3.linux环境下连接mysql出现错误:_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)") 

解决办法:将host为localhost改为127.0.0.1即可

 

posted @ 2019-07-12 16:13  顾明同学  阅读(307)  评论(0编辑  收藏  举报