社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
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
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>
6.用net start mysql 启动服务
7.重点
8.登录 第一次无密码登录
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>
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-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>
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
文章会根据官方文档持续更新,转发带上文字出处方便更新!
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!