这篇文章主要详细介绍了mysql 8.0.12 winx64解压版安装图文教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
解压到合适的目录:
F:\database\mysql-8.0.12-winx64
变量名 | 变量值 |
---|---|
MYSQL_HOME | F:\database\mysql-8.0.12-winx64 |
Path | %MYSQL_HOME%\bin |
在F:\database\mysql-8.0.12-winx64
目录下新建即可
[mysql]
; 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
;设置3306端口
port = 3306
; 设置mysql的安装目录(注意使用:\\)
basedir=F:\\database\mysql-8.0.12-winx64
; 设置mysql数据库的数据的存放目录(注意使用:\\)
datadir=F:\\database\mysql-8.0.12-winx64\\mydatabase
; 允许最大连接数
max_connections=200
; 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
; 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
使用CMD打开命令窗口,(获取初始密码,2种选择选取一种即可)
mysqld --initialize --console
命令,这样生成的随机密码(推荐)2020-05-16T12:01:51.247485Z 0 [System] [MY-013169] [Server] F:\database\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 6676
2020-05-16T12:02:07.745515Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Vue2K2dUtZ-5
假设成功,生成的 Vue2K2dUtZ-5
就是随机密码,后面需要用到
使用net start mysql
启动服务,如果出现下面的问题,请使用对应的方法解决
问题: Install/Remove of the Service Denied!
解决: 以管理员身份运行,打开CMD即可。
问题: 输入net start mysql 提示:服务名无效 请键入NET HELPING 2185以获得更多的帮助
解决: 请进入MySQL的bin目录,并在bin目录打开命令行窗口(管理员,否则会出现上面问题),在命令行窗口输入:
mysqld --install
,回车,提示:*Service successfully installed * ,即可启动服务net start mysql
。
登录并输入随机密码 mysql -u root -p
F:\database\mysql-8.0.12-winx64\bin>mysql -u root -p
Enter password: ************ -> Vue2K2dUtZ-5
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12
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.
mysql>
修改 newpassword 替换成你需要的新密码即可
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'newpassword';
如下
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'root';
Query OK, 0 rows affected (0.18 sec)
测试很简单,用新密码重新登录一次即可
mysql> exit
Bye
F:\database\mysql-8.0.12-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.12 MySQL Community Server - GPL
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.
mysql>