mysql准备
- 官网下载对应的zip包,我选择的(mysql-8.0.22-winx64.zip)
- 在mysql-8.0.22-winx64文件夹下面新建一个
my.ini
文件和一个data
文件夹 - my.ini中的内容
my.ini内容:
[mysqld]
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\\app\\mysql-8.0.22-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:\\app\\mysql-8.0.22-winx64\\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
- 我的电脑设置环境变量
- MYSQL_HOME=e:\app\mysql-8.0.22-winx64
- 在path中添加%MYSQL_HOME%\bin
mysql安装
- 已管理员身份打开cmd,输入
mysqld --initialize --user=mysql --console
发现弹出没有vcruntime140_1.dll
文件- 找到对应网站下载此dll
-
vcruntime140_1.dll
文件放到C:\Windows\System32
和C:\Windows\SysWOW64
下 - 运行下面的bat文件,进行注册
@echo 开始注册
copy vcruntime140_1.dll %windir%\system32\
regsvr32 %windir%\system32\vcruntime140_1.dll /s
@echo system32 vcruntime140_1.dll注册成功
copy vcruntime140_1.dll %windir%\SysWOW64\
regsvr32 %windir%\system32\vcruntime140_1.dll /s
@echo SysWOW64 vcruntime140_1.dll注册成功
@pause
- 初始化数据库
E:\>mysqld --initialize --user=mysql --console
2020-11-28T03:32:30.871296Z 0 [System] [MY-013169] [Server] E:\app\mysql-8.0.22-
winx64\bin\mysqld.exe (mysqld 8.0.22) initializing of server in progress as proc
ess 6964
2020-11-28T03:32:30.873294Z 0 [Warning] [MY-013242] [Server] --character-set-ser
ver: '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.
2020-11-28T03:32:30.884295Z 1 [System] [MY-013576] [InnoDB] InnoDB initializatio
n has started.
2020-11-28T03:32:33.331435Z 1 [System] [MY-013577] [InnoDB] InnoDB initializatio
n has ended.
2020-11-28T03:32:35.760574Z 6 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: JoyfjqHL5)SO
-
JoyfjqHL5)SO
这个就是得到的数据库密码 - 输入命令安装mysql
E:\>mysqld install
Service successfully installed.
- 启动mysql服务
E:\>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功
- 登陆mysql,粘贴刚刚生成的密码
E:\>mysql -u root -p
- 登陆成功后修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
- 刷新
FLUSH PRIVILEGES;
mysql连接
- 我这里使用heidisql
-
新建会话,输入密码,打开下面页面就说明已经成功连接数据库
image.png
网友评论