1.首先卸载其他版本(如果有的话)
2.下载mysql:https://dev.mysql.com/downloads/file/?id=484900
3.下载后,解压。在文件夹下新建my.ini文件
内容:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=E:\\mysql-8.0.15-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
4.cmd进入文件夹的bin目录
5.运行mysqld --initialize --console 会生成一个初始密码,登录后需要改掉密码,启动,
如果mysqld install 遇到《Install/Remove of the Service Denied》错误,请以管理员身份运行cmd
6.登录进去后,用初始密码进行操作会报错
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
只需要修改密码,记得加分号
alter user 'root'@'localhost' identified by '1234';
7.退出去后,用初始密码就登录不进来了,密码修改成功
8.mysql8版本连接Navicat的时候可能会报错,因为由于跟5.0的加密规则不一样,连接会报错2059,
只需要在mysql中修改一下(root:账户,localhost:地址,‘1234’:root的密码)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
Microsoft Windows [版本 10.0.17134.590]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\WINDOWS\system32>e:
E:\>cd mysql-8.0.15-winx64
E:\mysql-8.0.15-winx64>cd bin
E:\mysql-8.0.15-winx64\bin>mysqld --initialize --console
2019-02-14T05:11:25.389712Z 0 [System] [MY-013169] [Server] E:\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 12196
2019-02-14T05:11:25.393667Z 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-02-14T05:11:53.887371Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aCyqbos-!5K9
2019-02-14T05:12:06.238996Z 0 [System] [MY-013170] [Server] E:\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completed
E:\mysql-8.0.15-winx64\bin>mysqld install
Service successfully installed.
E:\mysql-8.0.15-winx64\bin>net start mysql
MySQL 服务正在启动 ....
MySQL 服务已经启动成功。
E:\mysql-8.0.15-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '1234'
-> ;
Query OK, 0 rows affected (0.18 sec)
E:\mysql-8.0.15-winx64\bin>mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
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 WITH mysql_native_password BY '1234';
Query OK, 0 rows affected (0.07 sec)
mysql>
参考菜鸟教程: