ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this st

本文记录一下我在mac环境下安装mysql-5.7.16遇到的坑。我用的是二进制文件tar.gz压缩包的形式安装。

1号坑

安装完成后,使用安装过程随机生成的密码登录,执行命令都是失败的,都会给出如下提示

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

查阅资料后才知道,原来是Password Expiration Policy搞的鬼,自从5.7.4版本后就有了这么一个东西(详情参考最后的参考网站)。执行下面的代码可解。

mysql> SELECT 1;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> ALTER USER USER() IDENTIFIED BY 'new_password';
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

启动

记得启动mysql是mysqld的命令,但是不能用root使用mysqld,否则打印如下错误

2016-11-17T13:54:04.161157Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

所以启动相关的命令如下

cd /usr/local/mysql  
# 启动 
support-files/mysql.server start  
# 重启
support-files/mysql.server restart  
# 停止
support-files/mysql.server stop  
# 检查 MySQL 运行状态
support-files/mysql.server status

允许mysql远程访问

  • 更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称’%’。
    或者新加条记录,“host” 项为要访问的ip地址,并授权。重启mysql服务。
  • 授权

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 

参考网站

http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
https://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html
http://blog.csdn.net/cin_ie/article/details/50364756

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值