下载网址:https://dev.mysql.com/downloads/mysql/
在C盘建立文件夹mysql8,并发下载的压缩文件放进去,并解压:
新建my.ini配置文件,并输入如下内容:
[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\Program Files\\mysql8\\mysql-8.0.29-winx64\\mysql-8.0.29-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\Program Files\\mysql8
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
以管理员身份运行cmd.exe
执行如下命令:
切换到安装目录:
cd C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin
初始化数据库;
mysqld --initialize --console
执行完成后,会打印root的初始密码: =aEB%&xdS4zo
输入以下安装命令:
mysqld install
启动输入以下命令即可:
net start mysql
C:\Windows\system32>cd C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin>mysqld --initialize --console 2022-05-21T05:08:32.502395Z 0 [System] [MY-013169] [Server] C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin\mysqld.exe (mysqld 8.0.29) initializing of server in progress as process 19696 2022-05-21T05:08:32.503495Z 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. 2022-05-21T05:08:32.521934Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-05-21T05:08:32.987543Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-05-21T05:08:33.877566Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =aEB%&xdS4zo C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin>mysqld install Service successfully installed. C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。 C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-winx64\bin>mysql -u root -p Enter password: ****** ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) C:\Program Files\mysql8\mysql-8.0.29-winx64\mysql-8.0.29-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.29 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> show database; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1 mysql> show database;
=========================================================================
下载Navicat;目前有14天免费试用期
设置连接名:myslq8;
用户名: root
密码: =aEB%&xdS4zo
创建一个新数据库,名为mysql8
参考网址:
https://blog.csdn.net/Dyoungwhite/article/details/122426288
https://www.runoob.com/mysql/mysql-install.html
修改新密码: 123456