. # inittab This file describes how the INIT process should set up
. # the system in a certain run-level.
. #
. # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
. # Modified for RHS Linux by Marc Ewing and Donnie Barnes
. #
. # Default runlevel. The runlevels used by RHS are:
. # 0 - halt (Do NOT set initdefault to this)
. # 1 - Single user mode
. # 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
. # 3 - Full multiuser mode
. # 4 - unused
. # 5 - X11
. # 6 - reboot (Do NOT set initdefault to this)
. #
. id:3:initdefault:
D:\Program Files\mysql-5.7.36-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
在输入命令 mysql -u root -p,不需要输入密码,直接回车
D:\Program Files\mysql-5.7.36-winx64\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
输入命令行 use mysql,进入数据库
mysql> use mysql
Database changed
输入命令行 update user set authentication_string=password("××××××") where user="root"; ××××××是你设置的新密码,敲击回车后若出现信息,证明修改成功
mysql> update user set authentication_string=password("123456") where user="root";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
启动任务管理器,在“服务”中找到 MySQL,点击右键,然后点击停止即可
然后在刚刚的 my.ini 文件中删除 skip-grant-tables 这一行并保存关闭
再次以管理员身份运行命令提示符,输入启动命令:net start mysql,再输入 mysql -u root -p,再输入刚刚设置的密码,出现以下信息证明设置成功
D:\Program Files\mysql-5.7.36-winx64\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
输入命令行 use mysql 验证一下,结果报错
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
既然没有重置密码,那就重置密码,键入命令行 alter user user() identified by "××××××";
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.00 sec)