我使用yum安装了MySQL 8.x,但是找不到或重置root密码 [英] I installed MySQL 8.x using yum, but I cannot find or reset the root password

查看:549
本文介绍了我使用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"plugin"切换为"component"-因此,如果您不需要他们坚持的安全级别并且想要一个可以记住的密码,则必须运行以下命令在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密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆