D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
没有启动 MySQL 服务。
请键入 NET HELPMSG 3521 以获得更多的帮助。
D:\Program Files\mysql-8.0.14-winx64\bin>sc delete MySQL
[SC] DeleteService 成功
D:\Program Files\mysql-8.0.14-winx64\bin>
然后再执行如下命令:
mysqld install
mysqld --initialize --user=mysql --console
C:\WINDOWS\system32>mysqld install
Service successfully installed.
C:\WINDOWS\system32>d:
d:\>cd D:\Program Files\mysql-8.0.14-winx64\bin
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>mysqld --initialize --user=mysql --console
2021-09-22T01:05:32.259900Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.14-winx64\bin\mysqld.exe (mysqld 8.0.14) initializing of server in progress as process 43156
2021-09-22T01:05:32.260994Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-09-22T01:05:34.700095Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: F<D2i2KkKTZf
2021-09-22T01:05:35.490416Z 0 [System] [MY-013170] [Server] D:\Program Files\mysql-8.0.14-winx64\bin\mysqld.exe (mysqld 8.0.14) initializing of server has completed
D:\Program Files\mysql-8.0.14-winx64\bin>
root@localhost: F<D2i2KkKTZf 中的 F<D2i2KkKTZf 就是系统默认密码
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.14
Copyright (c) 2000, 2019, 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>
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.07 sec)
mysql> exit;
D:\Program Files\mysql-8.0.14-winx64\bin>
mysql> update user set host='%' where user='root' and host='localhost';
mysql> select host, user from user;
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
mysql> flush privileges;
mysql> exit;
D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
D:\Program Files\mysql-8.0.14-winx64\bin>net start mysql
执行结果如下:
D:\Program Files\mysql-8.0.14-winx64\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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>
mysql>
mysql> use mysql;
Database changed
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.00 sec)
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
4 rows in set (0.00 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.05 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql>
mysql> exit;
Bye
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
D:\Program Files\mysql-8.0.14-winx64\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
没有启动 MySQL 服务。
请键入 NET HELPMSG 3521 以获得更多的帮助。
D:\Program Files\mysql-8.0.14-winx64\bin>sc delete MySQL
[SC] DeleteService 成功
D:\Program Files\mysql-8.0.14-winx64\bin>
然后再执行如下命令:
mysqld install
mysqld --initialize --user=mysql --console
C:\WINDOWS\system32>mysqld install
Service successfully installed.
C:\WINDOWS\system32>d:
d:\>cd D:\Program Files\mysql-8.0.14-winx64\bin
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>mysqld --initialize --user=mysql --console
2021-09-22T01:05:32.259900Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.14-winx64\bin\mysqld.exe (mysqld 8.0.14) initializing of server in progress as process 43156
2021-09-22T01:05:32.260994Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-09-22T01:05:34.700095Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: F<D2i2KkKTZf
2021-09-22T01:05:35.490416Z 0 [System] [MY-013170] [Server] D:\Program Files\mysql-8.0.14-winx64\bin\mysqld.exe (mysqld 8.0.14) initializing of server has completed
D:\Program Files\mysql-8.0.14-winx64\bin>
root@localhost: F<D2i2KkKTZf 中的 F<D2i2KkKTZf 就是系统默认密码
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.14
Copyright (c) 2000, 2019, 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>
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.07 sec)
mysql> exit;
D:\Program Files\mysql-8.0.14-winx64\bin>
mysql> update user set host='%' where user='root' and host='localhost';
mysql> select host, user from user;
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
mysql> flush privileges;
mysql> exit;
D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
D:\Program Files\mysql-8.0.14-winx64\bin>net start mysql
执行结果如下:
D:\Program Files\mysql-8.0.14-winx64\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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>
mysql>
mysql> use mysql;
Database changed
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.00 sec)
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
4 rows in set (0.00 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.05 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql>
mysql> exit;
Bye
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>
D:\Program Files\mysql-8.0.14-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
D:\Program Files\mysql-8.0.14-winx64\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
D:\Program Files\mysql-8.0.14-winx64\bin>