MySQL 8.0 ZIP版本安装及MySQL 8.0密码修改

一、下载

Win64下载地址: https://dev.mysql.com/downloads/mysql/

 

https://dev.mysql.com/downloads/file/?id=480557

二、解压

  1. 解压文件
  2. 新建或删除新建目录data
  3. 新建my.ini文件

     新建my.ini文件【红色部分自己根据自己的目录修改】

    将以下内容复制到新建的配置文件中,其中basedirdatadir设置mysql文件夹路径:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\mysql
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql\data
# 允许最大连接数
max_connections=10000
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
wait_timeout=86400
interactive_timeout=7200

 

三、环境变量配置

       MYSQL_HOME:D:\mysql

      在path 后面添加 ;%MYSQL_HOME%\bin

四、安装

  1. 打开cmd.exe,必须以管理员的身份运行
  2. 如不做环境配置,需要进入安装路径的\bin目录
  3. 初始化数据库

mysqld --initialize --user=mysql –console

执行如下:

C:\windows\system32>mysqld --initialize --user=mysql --console
2019-01-18T10:05:44.356340Z 0 [System] [MY-013169] [Server] D:\mysql\bin\mysqld.
exe (mysqld 8.0.13) initializing of server in progress as process 8664
2019-01-18T10:05:44.358482Z 0 [Warning] [MY-013242] [Server] --character-set-ser
ver: '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-01-18T10:05:52.696709Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: _pOpYSu-p4-Y
2019-01-18T10:05:55.858120Z 0 [System] [MY-013170] [Server] D:\mysql\bin\mysqld.
exe (mysqld 8.0.13) initializing of server has completed
2019-01-18T10:05:55.858120Z 0 [System] [MY-013170] [Server] D:\mysql\bin\mysqld.
exe (mysqld 8.0.13) initializing of server has completed

4.安装服务

      mysqld --install MySQL

      执行如下:

     C:\windows\system32>mysqld --install MySQL

      Service successfully installed.

5.启动服务

      net start MySQL

     执行如下:

    C:\windows\system32>net start MySQL

    MySQL 服务正在启动 ..

    MySQL 服务已经启动成功。

五、密码修改

1、cmd输入命令:

       mysql -u root -p

      输入上面的初始密码

      执行如下:

C:\windows\system32>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.13
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.

2、修改新密码

ALTER USER USER() IDENTIFIED BY '123456';

执行如下:

mysql> ALTER USER USER() IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.09 sec)

3、使用数据库

use mysql

执行如下:

mysql> use mysql

Database changed

4、查询当期的密码格式

select user,plugin from user where user='root';

执行如下:

mysql> select user,plugin from user where user='root';

+------+-----------------------+

| user | plugin                |

+------+-----------------------+

| root | caching_sha2_password |

+------+-----------------------+

1 row in set (0.00 sec)

5、修改密码格式

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'r

oot';

ALTER USER USER() IDENTIFIED BY '123456';

FLUSH PRIVILEGES;

执行如下:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

Query OK, 0 rows affected (0.09 sec)

mysql> ALTER USER USER() IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.09 sec)
mysql> select user,plugin from user where user='root';

+------+-----------------------+

| user | plugin                |

+------+-----------------------+

| root | mysql_native_password |

+------+-----------------------+

1 row in set (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

mysql>

六、连接测试

1) 以上已在命令行中测试过了;

2) 也可使用navicat premium 等客户端连接测试;

参考:

https://www.cnblogs.com/Michael1/p/5806384.html

https://www.cnblogs.com/--net/p/6796445.html

https://blog.csdn.net/qq_42909551/article/details/81710302

https://majing.io/posts/10000005531181

https://blog.csdn.net/weixin_40393909/article/details/80390315

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值