安装mysql-8.0.15-winx64.zip

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>

参考菜鸟教程:

http://www.runoob.com/mysql/mysql-install.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.A simple master-to-slave replication is currently being...
    Kevin关大大阅读 6,004评论 0 3
  • 什么是数据库? 数据库是存储数据的集合的单独的应用程序。每个数据库具有一个或多个不同的API,用于创建,访问,管理...
    chen_000阅读 4,056评论 0 19
  • 错误原因:在上述文件中,ERROR错误提示表明在执行mysqld --initialize时,需要data目录为空...
    羽墨_99e8阅读 1,294评论 0 1
  • mysqladmin -u root -p oldpass password newpass mysqladmin...
    不排版阅读 2,229评论 0 3
  • 《说女人》 文:姜子涵 大度的女人是一种美,是一种有着雪域高原的圣洁之美。...
    姜子涵阅读 258评论 0 2