https://downloads.mysql.com/archives/community/
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.30-winx64.zip
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.30-1.el9.x86_64.rpm-bundle.tar
my.ini
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\mysql-8.0.30-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql-8.0.30-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
cd D:\mysql-8.0.30-winx64\bin
mysqld --initialize --console
mysqld --install
net start mysql
mysql -h localhost -u root -p
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>d:
D:\>cd D:\mysql-8.0.30-winx64\bin
D:\mysql-8.0.30-winx64\bin>mysqld --initialize --console
2022-10-07T16:37:36.910431Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.30-winx64\bin\mysqld.exe (mysqld 8.0.30) initializing of server in progress as process 1856
2022-10-07T16:37:36.954432Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-07T16:37:41.087669Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-07T16:37:42.859771Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Mo?B=gkoo3Eo
D:\mysql-8.0.30-winx64\bin>mysqld --install
Service successfully installed.
D:\mysql-8.0.30-winx64\bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。
D:\mysql-8.0.30-winx64\bin>mysql -h localhost -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
D:\mysql-8.0.30-winx64\bin>mysql -h localhost -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.30
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.05 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.13 sec)
mysql>
mysql> use mysql
Database changed
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.02 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set, 1 warning (0.07 sec)
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>d:
D:\>cd D:\mysql-8.0.30-winx64\bin
D:\mysql-8.0.30-winx64\bin>
D:\mysql-8.0.30-winx64\bin>mysqld --initialize --console
2022-10-14T11:56:24.038002Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.30-winx64\bin\mysqld.exe (mysqld 8.0.30) initializing of
server in progress as process 7664
2022-10-14T11:56:24.317535Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-14T11:56:32.757607Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-14T11:56:37.481208Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: cs9_ypE5SgxF
D:\mysql-8.0.30-winx64\bin>
D:\mysql-8.0.30-winx64\bin>
D:\mysql-8.0.30-winx64\bin>mysqld --install
Service successfully installed.
D:\mysql-8.0.30-winx64\bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。
D:\mysql-8.0.30-winx64\bin>mysql -h localhost -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.17 sec)
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.03 sec)
mysql>
mysql>
mysql> use mysql
Database changed
mysql>
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.13 sec)
mysql>
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set, 1 warning (0.07 sec)
mysql>
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)
mysql>
mysql>
mysql>
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.17 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql>
mysql>
mysql> select host, user, authentication_string, 1 from mysql.user;
+-----------+------------------+------------------------------------------------------------------------+---+
| host | user | authentication_string | 1 |
+-----------+------------------+------------------------------------------------------------------------+---+
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 1 |
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | 1 |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | 1 |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | 1 |
+-----------+------------------+------------------------------------------------------------------------+---+
4 rows in set (0.00 sec)
mysql>