在 MySQL 8 中重置 root 密码 [英] Reset root password in MySQL 8
问题描述
当我使用 如何重置根密码,使用mysqld --init-file=/home/username/init-file
启动服务器不起作用.
When I use the method to reset the root password described on How to Reset the Root Password, starting the server with mysqld --init-file=/home/username/init-file
doesn't work.
它给出了以下错误.
[服务器] 无法打开/var/log/mysqld.log 文件以记录错误:权限被拒绝.
[Server] Could not open /var/log/mysqld.log file for error logging: Permission denied.
权限正确.
服务器在我使用 service mysqld start
时启动.
Server starts when I use service mysqld start
.
我在 Fedora 28 上使用 MySQL 8.0.12.
I am using MySQL 8.0.12 on Fedora 28.
推荐答案
如果您可以登录到您的 MySQL 服务器并且您想通过查询更改您的密码,您可以这样做:
If you can log in to your MySQL server and you want to change your password by query you can do it this queries:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
或删除root密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
感谢此博客:https://juejin.im/entry/5b06698cf265da0db3501fdd
在这里也回答了同样的问题:https://stackoverflow.com/a/54511940/1157720
Also answered the same question here: https://stackoverflow.com/a/54511940/1157720
这篇关于在 MySQL 8 中重置 root 密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!