时间:2021-07-01 10:21:17 帮助过:21人阅读
- MySQL 8.*版本 修改root密码
- 查看版本:select version() from dual;<br>
- 1.6. 登录mysql:
- 登录mysql:(因为之前没设置密码,所以密码为空,不用输入密码,直接回车即可)
- E:\mysql\bin>mysql -u root -p
- Enter password:<br>
- 1.7. 查询用户密码:
- 查询用户密码命令:mysql> select host,user,authentication_string from mysql.user;
- host: 允许用户登录的ip‘位置‘%表示可以远程;
- user:当前数据库的用户名;
- authentication_string: 用户密码(后面有提到此字段);<br>
- 1.8. 设置(或修改)root用户密码:
- 默认root密码为空的话 ,下面使用navicat就无法连接,所以我们需要修改root的密码。
- 这是很关键的一步。此处踩过N多坑,后来查阅很多才知道在mysql 5.7.9以后废弃了password字段和password()函数;authentication_string:字段表示用户密码。
- 下面直接演示正确修改root密码的步骤:<br>
- 一、如果当前root用户authentication_string字段下有内容,先将其设置为空,否则直接进行二步骤。
- use mysql;
- update user set authentication_string=‘‘ where user=‘root‘
- 3.下面直接演示正确修改root密码的步骤:<br>
- 二、使用ALTER修改root用户密码,方法为 ALTER user ‘root‘@‘localhost‘ IDENTIFIED BY ‘新密码‘。如下:
- ALTER user ‘root‘@‘localhost‘ IDENTIFIED BY ‘JOhydhLfMsWyBcn#‘
- 此处有两点需要注意:
- 1、不需要flush privileges来刷新权限。
- 2、密码要包含大写字母,小写字母,数字,特殊符号。
- 修改成功; 重新使用用户名密码登录即可;
MySQL 8.*版本 修改root密码,置空密码等
标签:内容 ica 无法 pass local root用户 ges 字母 默认