博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL: win10安装MySQL 8.0.21成功记录【转载】
阅读量:4031 次
发布时间:2019-05-24

本文共 9868 字,大约阅读时间需要 32 分钟。

參考博客原址:

主机配置:

拯救者R7000,win10,4600H

MySQL下载

MySQL直接去官网下载就行,选择community版本(免费)下载,链接:

选择community server-ZIP Archive安装包,第二个是调试文件。

安装与配置

将下载好的压缩包解压缩到全英文目录下,比如我在D盘新建了MySQL文件夹,解压到该文件夹下,D:/MySQL

然后把mysql 8.0.21所在的路径D:\MySQL\mysql-8.0.21-winx64添加到环境变量Path中

接下来正式安装和配置MySQL:

(一)首先在D:\MySQL\mysql-8.0.21-winx64路径下创建一个my.ini文件,直接新建文本文档,然后重命名为my.ini即可。

在文档中添加以下内容:

(注意修改basedir和datadir的路径)

注意服务端的字符集最好使用utf8mb4,这个才是真正意义的utf8,以后版本的utf8代表utf8mb3,代表3个字节的,而我们真正意义上的utf8是4字节的,所以使用utf8mb4,这次mysql的遗留问题。

[mysqld]      
# 设置3306端口
port=
3306
# 设置mysql的安装目录
basedir=D:\\MySQL\\mysql-
8.0.
21-winx64
# 此处为mysql的解压缩路径
# 设置mysql数据库的数据的存放目录
datadir=D:\\MySQL\\mysql-
8.0.
21-winx64\\Data
# 此处同上,先不要在路径中创建Data目录,后面初始化时会自动生成
# 允许最大连接数
max_connections=
200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=
10
# 服务端使用的字符集默认为UTF8,也可以使用utf8mb4,以后版本utf8代表mb3 !!! ###
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=
3306
default-character-set=utf8

(二)以管理员权限打开cmd(注意要以管理员权限打开),并将路径切换到D:\MySQL\mysql-8.0.21-winx64\bin

输入mysqld --initialize --console,进行初始化。该步可以得到mysql的初始密码,root@localhost后面那一串就是初始密码,以下为命令输入后的显示。

D:\MySQL\mysql-       
8.0.
21-winx64\bin>mysqld --initialize --console
2020
-05-10T11:
26:
21.895908Z
0 [System] [MY-
013169] [Server]
D:\MySQL\mysql-
8.0.
21-winx64\bin\mysqld.exe (mysqld
8.0.
21) initializing of server in progress as process
9764
2020
-05-10T11:
26:
21.897278Z
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.
2020
-05-10T11:
26:
21.915225Z
1 [System] [MY-
013576] [InnoDB] InnoDB initialization has started.
2020
-05-10T11:
26:
22.619057Z
1 [System] [MY-
013577] [InnoDB] InnoDB initialization has ended.
2020
-05-10T11:
26:
24.265774Z
6 [Note] [MY-
010454] [Server] A temporary password is generated for root
@localhost:
9Zh31zk-
@mof

输入mysqld --install(如果需要安装多个mysql服务,这步输入mysqld --install [服务名])

D:\MySQL\mysql-       
8.
0.
21-winx
64\bin>mysqld --install
Service successfully installed.

显示Service successfully installed则说明安装成功

输入net start mysql,启动MySQL服务

D:\MySQL\mysql-       
8.
0.
21-winx
64\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.

输入mysql -u root -p,使用初始密码登录mysql,在Enter password后输入初始密码

D:\MySQL\mysql-       
8.0.
21-winx64\bin>mysql -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.
21
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.

登录后,把初始密码修改掉,可以设置成自己容易记住的密码。

输入ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '自己定义的密码';(分号一定要带)

mysql> ALTER USER        
'root'@
'localhost' IDENTIFIED
WITH mysql_native_password BY
'自己定义的密码;
Query OK, 0 rows affected (0.02 sec)

到这一步就完成了

输入show databases;,可以查看包含哪些数据表

mysql> show databases;      
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows
in set (
0.
01 sec)

后处理:

安装完成mysql自动开启服务开机自启动,如不经常使用,可以使用net stop mysql关闭服务并将服务改为手动启动,使用 net start mysql 开启服务。

 

文章基本按的步骤进行,此处记录一下步骤,并验证8.0.21按该步骤也可以正常安装。

如果遇到问题,在中有一些解决方法,楼主没遇到问题。

参考:

转载地址:http://tkgbi.baihongyu.com/

你可能感兴趣的文章
gdb debug tips
查看>>
arm linux 生成火焰图
查看>>
jtag dump内存数据
查看>>
linux和windows内存布局验证
查看>>
linux config
查看>>
linux insmod error -1 required key invalid
查看>>
linux kconfig配置
查看>>
linux不同模块completion通信
查看>>
linux printf获得时间戳
查看>>
C语言位扩展
查看>>
linux dump_backtrace
查看>>
linux irqdebug
查看>>
git 常用命令
查看>>
linux位操作API
查看>>
snprintf 函数用法
查看>>
uboot.lds文件分析
查看>>
uboot start.s文件分析
查看>>
没有路由器的情况下,开发板,虚拟机Ubuntu,win10主机,三者也可以ping通
查看>>
本地服务方式搭建etcd集群
查看>>
安装k8s Master高可用集群
查看>>