安装mysql的安装包并解压
然后以管理员的身份打开cmd
如果不以管理员身份打开后面会出现一个问题
执行mysqld --install时
报错:
Install/Remove of the Service Denied
cd D:\Program Files\MySQL\mysql-8.0.18-winx64\bin
mysqld --initialize-insecure --user=mysql
mysqld -install
Service successfully installed.
net start MySQL
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
还没设置密码,密码为空
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.18 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> select host,user,authentication_string from mysql.user;
+-----------+------------------+------------------------------------------------------------------------+
| host | user | authentication_string |
+-----------+------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | $A$005$e{fQE{GI^Z`2x\*'/]fWuAe4xe8LiMKjR9gKih9gcdMuaSQhlNoGAc/nCCM713. |
+-----------+------------------+------------------------------------------------------------------------+
4 rows in set (0.02 sec)
mysql> use mysql
Database changed
mysql> quit
Bye
参考博客:https://www.cnblogs.com/zhangkanghui/p/9613844.html