1. zip包下载:
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-winx64.zip
解压缩,本案例解压到: e:\mysql
2. 配置:
(1)新建数据目录:
建立 e:\mydata\data
,一定保证data目录为空!!!
(2) 建立配置文件
在C盘根目录下建立文件 my.cnf,注意需要以 “管理员身份启动powershell”,并使用命令行:
notepad c:\my.cnf
文件内容:
[mysqld]
basedir=E:\\mysql
datadir=E:\\mydata\\data
(3)配置环境变量:
image.png3. 初始化和启动:
初始化命令:
E:\mysql\bin>mysqld --initialize --console
2022-03-21T08:37:59.412547Z 0 [System] [MY-013169] [Server] E:\mysql\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as process 10224
2022-03-21T08:37:59.466852Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-03-21T08:38:04.835952Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-03-21T08:38:14.737627Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9nu_bL_VFXjY
注意:最后一行表示 root用户的临时密码是:9nu_bL_VFXjY
启动数据库服务器:
E:\mysql\bin>mysqld --console
2022-03-21T08:39:00.626417Z 0 [System] [MY-010116] [Server] E:\mysql\bin\mysqld.exe (mysqld 8.0.28) starting as process 3672
2022-03-21T08:39:00.667679Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-03-21T08:39:01.692426Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-03-21T08:39:02.655316Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-03-21T08:39:02.658300Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-03-21T08:39:02.699647Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
2022-03-21T08:39:02.699861Z 0 [System] [MY-010931] [Server] E:\mysql\bin\mysqld.exe: ready for connections. Version: '8.0.28' socket: '' port: 3306 MySQL Community Server - GPL.
此信息表示启动成功!此窗口将被阻塞,保持打开状态即可!
4. 客户端接入,并修改密码:
另外打开一个cmd窗口接入,密码使用临时密码
C:\Users\john>mysql -uroot -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, 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>
密码修改:
mysql> alter user root@localhost identified with mysql_native_password by '123';
Query OK, 0 rows affected (0.05 sec)
mysql>
网友评论