MySQL5.7修改密码以及密码认证失败(Your password does not satisfy the current policy requirements)

这几天在配置MySQL时候遇到一些问题, 下面一一列出:

1. 表中字段问题

mysql安装完之后, 如果是自己测试使用, 一般都会修改一个简单的密码, 比如123456

但我在网上一般都找的修改密码都是进入数据库之后

UPDATE mysql.user SET password = PASSWORD(‘newpassword’) WHERE USER = ‘root’;

FLUSH PRIVILEGES;

但其实是需要看自己的mysql数据库的一个user表字段的(如下图字段)

 mysql数据库的字段如下

这个其实是mysql版本问题

此时要修改的话就是(如下图)

update user set authentication_string=passworD("123456") where user='root';

但此时我修改密码时候有一个错误, 意思就是我密码不合法 

 2. 密码合法问题

此时首先得看一下自己当前密码安全策略设置的一些参数

SHOW VARIABLES LIKE 'validate_password%'; 

这里借用一下

 然后只用修改密码长度和密码级别就ok了

set global validate_password_policy=0;
set global validate_password_length=6;

 然后进行一个密码修改

alter user 'root'@'localhost' identified by '123456';

 

成功之后就可以用新密码登录了 

3. 远程连接失败

此时我可以本地登录数据库, 但是远程连接时候仍然有错误(远程连接不上)

输入下面命令之后报错

grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option

报错内容: 

 然后搜一下得知(可以用下面命令)

create user root@'%' identified by '123456';
 
grant all privileges on *.* to root@'%' with grant option;

最后刷新一下

flush privileges;

我自己的服务器是用这个命令修改完密码之后, 重启一下mysql, 然后成功远程连接的

mysqladmin -uroot -p123456 password 123456

service mysqld restart

  结果图如下:

 4. 重启MySQL失败Failed to restart mysql.service: Unit not found.

我在百度搜了一下, MySQL重启的几种命令(因为安装或者配置文件的差异问题)

第一种:

systemctl restart mysql.service

第二种:

service mysql restart

第三种

service mysqld restart

后来发现是自己MySQL的服务命问题, 然后我的MySQL服务名是mysqld, 用了第三种方式启动成功了....

参考文章:

Linux系统如何修改MySQL密码 - 云+社区 - 腾讯云

mysql报错 Your password does not satisfy the current policy requirements_ayychiguoguo的博客-CSDN博客

mysql远程连接权限grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option语句报错_chenshida_的博客-CSDN博客

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Expert PHP and MySQL takes you beyond learning syntax to showing you how to apply proven software development methods to building commerce-grade PHP and MySQL projects that will stand the test of time and reliably deliver on customer needs. Developers of real-world applications face numerous problems that seem trivial on the surface, but really do take some skill to get right. Error handling is about more than just the mechanics in the PHP syntax, but also about handling MySQL errors, logging those errors, and about hiding information about application internals that error messages sometimes can expose. Meet these challenges and more head-on! Author Marc Rochkind shows how to begin a project right, with a clear contract and set of written requirements. You’ll learn about project organization, setting up a solid development environment, connecting with client personnel. Database design is essential, and Expert PHP and MySQL has you covered with guidance on creating a sound model and database, and on pushing functionality into the database as appropriate; not everything should be done in PHP. Error handling is covered at both the PHP and MySQL levels. Application structure is covered. Guidance is provided on reporting. And finally there is conversion. In Expert PHP and MySQL you’ll explore the following: The popular and widely used combination of PHP and MySQL Commercial-grade application of language and database features Human factors such as planning and organization Organizing a project to meet requirements and satisfy the customer Structuring an application for efficient development and future modification Coding PHP for productivity, reliability, security Generating online, downloadable, and printed reports Converting existing data to the new application

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值