mysql windows 下安装 mysql zip 加获取零时密码 无密码登录策略 和 一些采坑记录 - Go语言中文社区

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


1.官网下载zip包

 

2.放到本地某个盘中

解压到当前目录下

 

3.windows 中大部分没有 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:mysqlmysql-8.0.15-winx64
datadir=E:mysqlmysql-8.0.15-winx64data
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#
default_authentication_plugin=mysql_native_password
  • data 目录会自动生成

 

5.在bin目录下输入命令

E:mysqlmysql-8.0.15-winx64bin>mysqld install
Service successfully installed.

E:mysqlmysql-8.0.15-winx64bin>mysqld --initialize

E:mysqlmysql-8.0.15-winx64bin>
E:mysqlmysql-8.0.15-winx64bin>net start mysql
MySQL 服务正在启动 ....
MySQL 服务已经启动成功。


E:mysqlmysql-8.0.15-winx64bin>
  • 如果发现data 目录出现了就说明安装成功了

 

6.用net start mysql 启动服务

 

7.重点

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

 

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

  • 8.0之前可以在my.ini 中设置 skip-grant-table
  • 8.0之后 命令行输入 mysqld --console --skip-grant-tables --shared-memor
E:mysqlmysql-8.0.15-winx64bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。


E:mysqlmysql-8.0.15-winx64bin>mysqld --console --skip-grant-tables --shared-memory
2019-03-05T10:13:48.237493Z 0 [System] [MY-010116] [Server] E:mysqlmysql-8.0.15-winx64binmysqld.exe (mysqld 8.0.15) starting as process 2244
2019-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 writable
2019-03-05T10:13:48.371796Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2019-03-05T10:13:48.371844Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2019-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] Aborting
2019-03-05T10:13:48.398847Z 0 [System] [MY-010910] [Server] E:mysqlmysql-8.0.15-winx64binmysqld.exe: Shutdown complete (mysqld 8.0.15)  MySQL Community Server - GPL.

E:mysqlmysql-8.0.15-winx64bin>

 

  • 然后打开一个新的cmd 命令行界面输入 mysql -uroot -p 直接回车 回车 就进去了 
E:mysqlmysql-8.0.15-winx64bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
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>

 

获取密码还有一种方式:

  • 将E:mysqlmysql-8.0.15-winx64data中的内容都删掉然后 mysqld --initialize --console 初始化一下 
  • 也可以在一开始 调用 mysqld --initialize  的时候就加上 --console 
E:mysqlmysql-8.0.15-winx64bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。


E:mysqlmysql-8.0.15-winx64bin>mysqld --initialize --console
2019-03-05T11:11:00.377576Z 0 [System] [MY-013169] [Server] E:mysqlmysql-8.0.15-winx64binmysqld.exe (mysqld 8.0.15) initializing of server in progress as process 5496
2019-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!aqhEha8Vw
2019-03-05T11:11:51.321276Z 0 [System] [MY-013170] [Server] E:mysqlmysql-8.0.15-winx64binmysqld.exe (mysqld 8.0.15) initializing of server has completed

E:mysqlmysql-8.0.15-winx64bin>
  • 在打印出来的倒数第二行 [Note] 最后有零时密码  for root@localhost: hV!aqhEha8Vw
  • 2019-03-05T11:11:40.711827Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hV!aqhEha8Vw
  • 拿这个来登录然后再修改自己想要的密码
E:mysqlmysql-8.0.15-winx64bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 10
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> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.11 sec)

mysql>
  • 密码就是上边那个

 

ok

 

 

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

 

 

 

 

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_42749765/article/details/88186370
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 15:19:22
  • 阅读 ( 1088 )
  • 分类:数据库

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢