大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说如何在MySQL 8中重置root密码[通俗易懂],希望您对编程的造诣更进一步.
ERROR 1045 (28000): Access denied for user “root”@”localhost” (using password: YES)
一般这个错误是由密码错误引起,解决的办法自然就是重置密码
解决方案如下:
1.停止mysql数据库:
systemctl stop mysqld
2.用以下命令启动MySQL,以不检查权限的方式启动:
mysqld –skip-grant-tables &
此时又报了一个错误:
2020-01-30T12:56:04.313195Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 14214 [20:56:04]
2020-01-30T12:56:04.314429Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root!
2020-01-30T12:56:04.314465Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-01-30T12:56:04.314565Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server – GPL.
执行命令:
mysqld –user=root –skip-grant-tables &
2020-01-30T12:57:00.762096Z 0 [Warning] [MY-010091] [Server] Can”t create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test [20:57:00]
2020-01-30T12:57:00.762156Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 14230
2020-01-30T12:57:00.764479Z 0 [Warning] [MY-010091] [Server] Can”t create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2020-01-30T12:57:00.764489Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-01-30T12:57:00.764672Z 0 [Warning] [MY-010122] [Server] One can only use the –user switch if running as root
权限不够 +
2020-01-30T12:57:00.764685Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to “/var/lib/mysql/” (OS errno: 13 – Permission denied)
2020-01-30T12:57:00.764764Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-01-30T12:57:00.764861Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server – GPL.
[1] + 14230 exit 1 mysqld –user=root –skip-grant-tables
3.登录mysql:mysql -uroot或mysql
4.更新root密码
mysql5.7以下版本:UPDATE mysql.user SET Password=PASSWORD(“123456″) where USER=”root”;
mysql8.0版本:UPDATE mysql.user SET authentication_string=”123456″ WHERE user=”root”;
5.刷新权限:
flush privileges;
6.退出mysql:exit或quit
7.使用root用户重新登录mysql
mysql -uroot -p
Enter password:<输入新设的密码123456>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/10129.html