mysql8.0.20安装教程
Posted 快乐崇拜234
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8.0.20安装教程相关的知识,希望对你有一定的参考价值。
欢迎关注本人公众号
mysql8 的安装先比较之前的版本复杂了一些,下面就一步一步安装。
下载
到 mysql官网 下载最新版本的mysql
下载完成后解压,并新建my.ini
文件
my.ini 文件配置
my.ini
文件内容:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=C:\\Program Files\\mysql-8.0.20-winx64
# 设置mysql数据库的数据的存放目录
datadir=C:\\Program Files\\mysql-8.0.20-winx64\\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
环境变量配置
环境变量中配置MySQL的bin的地址:
初始化MySQL
以管理员权限运行CMD:
输入mysqld --initialize --console
注意,这里的root@localhost: wD3l-a.r=2yP
时用户名和密码,先记录下来。
安装并启动MySQL服务
C:\\Program Files\\mysql-8.0.20-winx64\\bin>mysqld --initialize --console
2020-07-03T07:59:08.324357Z 0 [System] [MY-013169] [Server] C:\\Program Files\\mysql-8.0.20-winx64\\bin\\mysqld.exe (mysqld 8.0.20) initializing of server in progress as process 17184
2020-07-03T07:59:08.352557Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-03T07:59:09.538150Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-03T07:59:10.701709Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wD3l-a.r=2yP
C:\\Program Files\\mysql-8.0.20-winx64\\bin>mysqld --install
Service successfully installed.
C:\\Program Files\\mysql-8.0.20-winx64\\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
修改密码
先用刚从的初始密码登陆,然后用alter user 'root'@'localhost' identified by '123456';
命令修改密码。
C:\\Program Files\\mysql-8.0.20-winx64\\bin>mysql -uroot -pwD3l-a.r=2yP
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 11
Server version: 8.0.20
Copyright (c) 2000, 2020, 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.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
注意:
- 我们安装的时mysql8 版本,
update mysql.user set password='newpassword' where user='root';
和update mysql.user set password=PASSWORD('newpassword') where User='root';
这两条命令已经失效。 flush privileges;
刷新命令不可以省略哦
使用新密码登陆
C:\\Program Files\\mysql-8.0.20-winx64\\bin>mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 12
Server version: 8.0.20 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.02 sec)
以上是关于mysql8.0.20安装教程的主要内容,如果未能解决你的问题,请参考以下文章