mysql windows 下安装 mysql zip 加获取零时密码 无密码登录策略 和 一些采坑记录

网友投稿 692 2022-09-02

mysql windows 下安装 mysql zip 加获取零时密码 无密码登录策略 和 一些采坑记录

mysql  windows 下安装 mysql zip 加获取零时密码  无密码登录策略 和 一些采坑记录

1.官网-zip包

​​中大部分没有 data 目录和 my-default.ini

自己建立一个my.ini

4.将下面的代码拷入自己建一个my.ini文件

[mysql]# 设置mysql客户端默认字符集default-character-set=utf8 [mysqld]default-time-zone='+08:00'# 设置3306端口port = 3306# 设置mysql的安装目录basedir=E:\mysql\mysql-8.0.15-winx64datadir=E:\mysql\mysql-8.0.15-winx64\data#允许最大连接数max_connections=200#服务端使用的字符集默认为8比特编码的latin1字符集character-set-server=utf8#创建新表时将使用的默认存储引擎default-storage-engine=INNODB#default_authentication_plugin=mysql_native_password

data 目录会自动生成

5.在bin目录下输入命令

E:\mysql\mysql-8.0.15-winx64\bin>mysqld installService successfully installed.E:\mysql\mysql-8.0.15-winx64\bin>mysqld --initializeE:\mysql\mysql-8.0.15-winx64\bin>E:\mysql\mysql-8.0.15-winx64\bin>net start mysqlMySQL 服务正在启动 ....MySQL 服务已经启动成功。E:\mysql\mysql-8.0.15-winx64\bin>

如果发现data 目录出现了就说明安装成功了

6.用net start mysql 启动服务

7.重点

需要用管理员模式打开命令行cmd

8.登录 第一次无密码登录

8.0之前可以在my.ini 中设置 skip-grant-table8.0之后 命令行输入 mysqld --console --skip-grant-tables --shared-memor

E:\mysql\mysql-8.0.15-winx64\bin>net start mysqlMySQL 服务正在启动 ...MySQL 服务已经启动成功。E:\mysql\mysql-8.0.15-winx64\bin>mysqld --console --skip-grant-tables --shared-memory2019-03-05T10:13:48.237493Z 0 [System] [MY-010116] [Server] E:\mysql\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) starting as process 22442019-03-05T10:13:48.241066Z 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-03-05T10:13:48.371769Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable2019-03-05T10:13:48.371796Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable2019-03-05T10:13:48.371844Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine2019-03-05T10:13:48.372336Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.2019-03-05T10:13:48.397825Z 0 [ERROR] [MY-010119] [Server] Aborting2019-03-05T10:13:48.398847Z 0 [System] [MY-010910] [Server] E:\mysql\mysql-8.0.15-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.15) MySQL Community Server - GPL.E:\mysql\mysql-8.0.15-winx64\bin>

然后打开一个新的cmd 命令行界面输入 mysql -uroot -p 直接回车 回车 就进去了

E:\mysql\mysql-8.0.15-winx64\bin>mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.15 MySQL Community Server - GPLCopyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

获取密码还有一种方式:

将E:\mysql\mysql-8.0.15-winx64\data中的内容都删掉然后 mysqld --initialize --console 初始化一下也可以在一开始 调用 mysqld --initialize  的时候就加上 --console

E:\mysql\mysql-8.0.15-winx64\bin>net stop mysqlMySQL 服务正在停止.MySQL 服务已成功停止。E:\mysql\mysql-8.0.15-winx64\bin>mysqld --initialize --console2019-03-05T11:11:00.377576Z 0 [System] [MY-013169] [Server] E:\mysql\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server in progress as process 54962019-03-05T11:11:00.379725Z 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-03-05T11:11:40.711827Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hV!aqhEha8Vw2019-03-05T11:11:51.321276Z 0 [System] [MY-013170] [Server] E:\mysql\mysql-8.0.15-winx64\bin\mysqld.exe (mysqld 8.0.15) initializing of server has completedE:\mysql\mysql-8.0.15-winx64\bin>

在打印出来的倒数第二行 [Note] 最后有零时密码  for root@localhost: hV!aqhEha8Vw2019-03-05T11:11:40.711827Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hV!aqhEha8Vw拿这个来登录然后再修改自己想要的密码

E:\mysql\mysql-8.0.15-winx64\bin>mysql -u root -pEnter password: ************Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 10Server version: 8.0.15Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';Query OK, 0 rows affected (0.11 sec)mysql>

密码就是上边那个

ok

文章会根据官方文档持续更新,转发带上文字出处方便更新!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:TP5 paginate()分页后给结果集追加字段和数据(tp53基因突变靶向药)
下一篇:PHP高并发优化处理——redis层面详细步骤
相关文章

 发表评论

暂时没有评论,来抢沙发吧~