下载Mysql
操作系统:Windows10 64bit
下载地址为:点击下载
备注:博主自测8.0.15,其他版本请参考官方文档
解压安装
- 将zip文件解压到安装目录
2. 在mysql8.0.15目录下新建my.ini文件
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\Program\mysql-8.0.15
# 设置mysql数据库的数据的存放目录
datadir=D:\Program\mysql-8.0.15\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
配置环境变量
注意:上图红框中地址填写mysql安装目录的bin地址。
初始化配置
注意:使用CMD或PowerShell时,需要使用管理员权限。
PS D:\Program\mysql-8.0.15\bin> .\mysqld.exe --initialize --console
2019-05-13T03:30:28.921544Z 0 [System] [MY-013169] [Server] D:\Program\mysql-8.0.15\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 2320
2019-05-13T03:30:28.943549Z 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.
2019-05-13T03:30:33.708799Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 3iqu>uj7k;zK
2019-05-13T03:30:35.551163Z 0 [System] [MY-013170] [Server] D:\Program\mysql-8.0.15\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
出现"initializing of server has completed"则配置完成。这里的root登录的临时密码在"root@localhost:"的后面。
安装服务
PS D:\Program\mysql-8.0.15\bin> .\mysqld.exe --install
Service successfully installed.
安装完成。
启动服务
方法1-CMD
PS C:\Windows\system32> net start MYSQL
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
服务启动成功。
方法2-启动服务
登录
使用命令行登录mysql
PS D:\Program\mysql-8.0.15\bin> .\mysql.exe -uroot -p3iqu>uj7k;zK
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
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> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
mysql> FLUSH PRIVILEGES;
备注:也使用Navicat登录mysql系统会提示修改密码。
查看字符集信息
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | D:\Program\mysql-8.0.15\share\charsets\ |
| collation_connection | utf8mb4_0900_ai_ci |
| collation_database | utf8mb4_0900_ai_ci |
| collation_server | utf8mb4_0900_ai_ci |
+--------------------------+-----------------------------------------+
11 rows in set, 1 warning (0.00 sec)