1.下载地址
mysql解压版下载地址
2.解压后的文件更名为mysql,放置在指定纯英文路径文件夹,本文放置在d:/develop文件夹下
3.以管理员身份运行CMD,执行代码如下:
3.1初始化
D:\develop\mysql\bin>mysqld --initialize --user=mysql --console
得到结果
2019-04-01T05:30:44.243021Z 0 [System] [MY-013169] [Server] D:\develop\mysql\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 7256
2019-04-01T05:31:07.351423Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 1Rl4ffRnt,R=
2019-04-01T05:31:15.690623Z 0 [System] [MY-013170] [Server] D:\develop\mysql\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
保存临时密码:1Rl4ffRnt,R=
3.2安装
D:\develop\mysql\bin>mysqld --install MySQL
得到结果
Service successfully installed.
3.3启动服务
D:\develop\mysql\bin>net start MySQL
得到结果
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
3.4登录
D:\develop\mysql\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.15
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命令末尾加;
3.5在尝试调出databases的时候出现了报错
mysql> show databases;
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.15 sec)
3.6 之后退出服务重新登录检验之前的设置
mysql> exit;
Bye
D:\develop\mysql\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.15 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec)
mysql>