mysql操作相关错误解决办法

蔚落 2021-10-19 12:30 446阅读 0赞

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

解决办法:

  1. step 1: SET PASSWORD = PASSWORD('your new password');
  2. step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
  3. 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 “密码”;

  1. grant all privileges on my_test.* to root@localhost identified by '';
  2. 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即可

转载于:https://www.cnblogs.com/easyself/p/11176730.html

发表评论

表情:
评论列表 (有 0 条评论,446人围观)

还没有评论,来说两句吧...

相关阅读