Install MySQL 8 on Windows 10 64bit
下载
下载地址:https://dev.mysql.com/downloads/mysql/8.0.html
1.解压
mysql-8.0.19-winx64.zip
演示文件目录
C:\Program Files\mysql-8.0.19-winx64
2.创建两个文件夹
C:\Program Files\mysql-8.0.19-winx64\data
C:\Program Files\mysql-8.0.19-winx64\logs
3.设置环境变量
4.新建my.ini配置
[mysqld]
#安装目录
basedir = C:\Program Files\mysql-8.0.19-winx64
#数据文件目录
datadir = C:\Program Files\mysql-8.0.19-winx64\data
port = 3306
server_id = 1
general_log = ON
general_log_file = C:\Program Files\mysql-8.0.19-winx64\logs\mysql.log
log_error = C:\Program Files\mysql-8.0.19-winx64\logs\error.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server = utf8mb4
performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256
#sql_mode=ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
5.管理员权限开启CMD窗口
5.1 初始化
mysqld --initialize --console #不用特别指定default file默认会使用my.ini
控制台输入如下表示成功
C:\Program Files\mysql-8.0.19-winx64>mysqld --initialize --console
2020-04-21T10:11:25.148253Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-21T10:11:25.148318Z 0 [System] [MY-013169] [Server] C:\Program Files\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 8684
2020-04-21T10:11:47.571686Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Fv?_a7%jn_R(
Warning
暂时没做理会,没发现使用异常
记下上面日志最后面的root的初始化密码Fv?_a7%jn_R(
,下面要用到
5.2 安装服务
mysqld --install [服务名] #不写服务名默认为mysql
5.3 启动数据库
C:\Program Files\mysql-8.0.19-winx64>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
5.4 使用临时密码登陆数据库
C:\Program Files\mysql-8.0.19-winx64>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.19
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.
5.5 修改root初始化密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '要改的新密码';
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »