我使用 yum 安装 MySQL 8.x,但找不到或重置 root 密码

I installed MySQL 8.x using yum, but I cannot find or reset the root password(我使用 yum 安装 MySQL 8.x,但找不到或重置 root 密码)
本文介绍了我使用 yum 安装 MySQL 8.x,但找不到或重置 root 密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不安装 mysql 8.0,因为以前的版本崩溃了.
现在我正在努力设置root密码.默认的空密码不起作用,我尝试将 rootmysql 作为密码,但它们不起作用.
我已经创建了初始化文件来重置密码.不幸的是,我的密码不被接受,这是我的日志:

I had to install mysql 8.0 because previous version were crashing.
Now I'm struggling with setting root password. The default empty password doesn't work, I've tried root, mysql as passwords but they are not working.
I've created the init file to reset password. Unfortunately, my passwords are not accepted, here is my log:

2018-02-16T10:12:22.962733Z 0 [Warning] [MY-010139] Changed limits: max_open_files: 5000 (requested 8161)
2018-02-16T10:12:22.962815Z 0 [Warning] [MY-010142] Changed limits: table_open_cache: 2419 (requested 4000)
2018-02-16T10:12:23.160066Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc-log) starting as process 20059 ...
2018-02-16T10:12:24.013727Z 0 [Warning] [MY-010068] CA certificate ca.pem is self signed.
2018-02-16T10:12:24.026122Z 0 [Warning] [MY-010319] Found invalid password for user: 'root@localhost'; Ignoring user
2018-02-16T10:12:24.043758Z 6 [Warning] [MY-010319] Found invalid password for user: 'root@localhost'; Ignoring user
2018-02-16T10:12:24.050668Z 0 [System] [MY-010931] /usr/sbin/mysqld: ready for connections. Version: '8.0.4-rc-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL).

这是我当前的初始化文件内容:

Here is my current init file content:

SET GLOBAL validate_password.policy = 'LOW';
UPDATE mysql.user
    SET authentication_string = PASSWORD('new_password'), password_expired = 'N'
    WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;

我尝试了很多不同的密码,但都没有奏效.我尝试使用特殊字符和数字创建长度超过 16 个字符的密码,什么都没有.有什么建议我可以做些什么来重置密码并真正开始使用 DB?

I've tried so much different passwords, none worked. I've tried to create passwords longer than 16 characters with special characters and numbers, nothing. Any advices what I could do to reset the password and actually start using DB?

推荐答案

我也遇到了同样的问题.看起来他们用新版本更改了初始身份验证步骤.这里给出了说明.基本上:

I had the same problem. Looks like they changed the initial authentication steps with the new version. Instructions are given here. Basically:

$ sudo service mysqld start
$ sudo grep 'temporary password' /var/log/mysqld.log

(在下面使用该密码 - 或登录 mysql_secure_installation)

(use that password in the following - or to log into mysql_secure_installation)

$ mysql -uroot -p
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPasswd';

注意:他们还从 validate_password 插件"切换到组件" - 因此,如果您不需要他们坚持的安全级别并且想要一个您可以记住的密码,您必须运行以下命令在mysql中:

Note: they also switched from the validate_password "plugin" to a "component" - so if you don't need the levels of security they insist on and want a password you can remember, you'll have to run the following within mysql:

> UNINSTALL COMPONENT 'file://component_validate_password';

他们还更改了身份验证插件以支持更好的加密.如果您正在使用 Workbench 或其他附加组件并遇到这些错误

They've also changed the authentication plugin to support better encryption. If you're using Workbench or other add-ons and get an error along these lines

Authentication plugin 'caching_sha2_password' cannot be loaded:
/usr/local/mysql/lib/plugin/caching_sha2_password.so not found

然后使用以下方法调整用户密码:

Then use the following to adjust the user password:

> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newPasswd';

您可能还应该在/etc/my.cnf 中添加(或取消注释,如果已经存在)以下行

You should probably also add (or uncomment if already there) the following line to /etc/my.cnf

default-authentication-plugin=mysql_native_password

这篇关于我使用 yum 安装 MySQL 8.x,但找不到或重置 root 密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)