1、到mysql官网下载mysql5.7.41版本
下载地址:https://downloads.mysql.com/archives/community/
2、把下载的zip包加压到放到对应的目录下(自己可以选择)
image.png3、在当前目录创建一个my.ini文
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\java\soft\\mysql-5.7
# 设置mysql数据库的数据的存放目录
datadir=C:\\java\\soft\\mysql-5.7\\data
# 允许最大连接数
max_connections=2000
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
注意:目录的\斜杠,一定要改成双斜杠,不然会报无法创建目录的错误
4、初始化 MySQL 数据库
mysqld --initialize --console
C:\java\soft\mysql-5.7\bin>mysqld --initialize --console
2023-05-29T03:53:24.875680Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-05-29T03:53:24.877829Z 0 [ERROR] Can't find error-message file 'C:\java oft\mysql-5.7\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-05-29T03:53:25.066826Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-05-29T03:53:25.103860Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-05-29T03:53:25.199696Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5ce88b0b-fdd4-11ed-9a60-902e16553fd6.
2023-05-29T03:53:25.204935Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-05-29T03:53:25.583132Z 0 [Warning]
2023-05-29T03:53:25.583436Z 0 [Warning]
2023-05-29T03:53:25.586964Z 0 [Warning] CA certificate ca.pem is self signed.
2023-05-29T03:53:25.637938Z 1 [Note] A temporary password is generated for
root@localhost: fycju&ZI3dOr (当前root的密码)
5、安装 MySQL 服务
mysqld install
6、启动 MySQL 服务
在命令行窗口中执行以下命令启动 MySQL 服务
net start mysql
7、使用如下命令登录
mysql -uroot -p
# 会报错
mysql> show databases;
ERROR 1820 (HY000): Unknown error 1820
原因是需要重新改一下密码,使用如下命令:
alter user user() identified by '新密码';
网友评论