mysql-8.0.11-winx64.zip 下载地址:https://dev.mysql.com/downloads/file/?id=476233
mysql-8.0.11-winx64.zip 安装文档:https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html
基本步骤:
1.zip下载后解压到目录 C:\Program Files\MySQL\mysql-8.0.11-winx64 ,新建文件夹data
2.新建 my.ini 文件 内容如下:
[mysqld]
basedir = C:\Program Files\MySQL\mysql-8.0.11-winx64
datadir = C:\Program Files\MySQL\mysql-8.0.11-winx64\data
port = 3306
3. 添加环境变量
操作如下:
1)右键单击我的电脑->属性->高级系统设置(高级)->环境变量
点击系统变量下的新建按钮
输入变量名:MYSQL_HOME
输入变量值: C:\Program Files\MySQL\mysql-8.0.11-winx64
#即为mysql的自定义解压目录。
2)选择系统变量中的Path
点击编辑按钮
在变量值中添加变量值:%MYSQL_HOME%\bin
4.cmd 以管理员命令运行:
#切换到bin目录
C:\WINDOWS\system32>cd C:\Program Files\MySQL\mysql-8.0.11-winx64\bin
#执行安装命令
C:\Program Files\MySQL\mysql-8.0.11-winx64\bin>mysqld install MySQL --defaults-file="C:\Program Files\MySQL\mysql-8.0.11-winx64\my.ini"
Service successfully installed.
#初始化MySQL基础数据(很重要***)
C:\Program Files\MySQL\mysql-8.0.11-winx64\bin>mysqld --initialize-insecure
#启动服务
C:\Program Files\MySQL\mysql-8.0.11-winx64\bin>net start MySQL
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
使用navicat 用户名root 密码 root 登录 或者 不用密码登录。
如果 报错2059。修改一下root密码
C:\Program Files\MySQL\mysql-8.0.11-winx64\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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.06 sec)
mysql> use mysql;
Database changed
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.20 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)
参考文档:https://blog.csdn.net/houxuehan/article/details/49280945