C:\Windows\system32>cd C:\Program Files\MySQL\mysql-5.7.30-winx64\bin
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>mysqld -install
Service successfully installed.
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>mysqld --initialize
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
/**
* 此时在my.ini文件中任意处添加:skip-grant-tables
*/
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:\Program Files\MySQL\mysql-5.7.30-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.30 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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
Database changed
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> exit
Bye
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:\Program Files\MySQL\mysql-5.7.30-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.30
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql
Database changed
mysql> exit
Bye
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
C:\Program Files\MySQL\mysql-5.7.30-winx64\bin>