1、下载zip安装包:
MySQL8.0 For Windows zip包下载地址:https://dev.mysql.com/downloads/file/?id=476233,进入页面后可以不登录。后点击底部“No thanks, just start my download.”即可开始下载。
2、安装
2.1 解压zip包到安装目录,例如:D:\Lenovo\MySQL
2.3 配置初始化的my.ini文件
在安装根目录下添加 my.ini(新建文本文件,将文件类型改为.ini),
写入基本配置:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\Lenovo\\MySQL # 切记此处一定要用双斜杠\\,单斜杠我这里会出错,不过看别人的教程,有的是单斜杠。自己尝试吧
# 设置mysql数据库的数据的存放目录
datadir=D:\\Lenovo\\MySQL\\Data # 此处同上
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
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
3、安装mysql
在安装时,必须以管理员身份运行cmd,否则在安装时会报错,会导致安装失败的情况
mysqld --initialize --console
C:\WINDOWS\system32>D:
D:\>cd D:\Lenovo\MySQL\bin
D:\Lenovo\MySQL\bin>mysqld --initialize --console
2019-06-13T15:59:38.541223Z 0 [System] [MY-013169] [Server] D:\Lenovo\MySQL\bin\mysqld.exe (mysqld 8.0.16) initializing of server in progress as process 14244
2019-06-13T15:59:38.590713Z 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.
2019-06-13T16:00:06.190039Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: k:ww7Og7lCDg
2019-06-13T16:00:19.710063Z 0 [System] [MY-013170] [Server] D:\Lenovo\MySQL\bin\mysqld.exe (mysqld 8.0.16) initializing of server has completed
注意!执行输出结果里面有一段:
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost:k:ww7Og7lCDg
其中root@localhost:后面的“k:ww7Og7lCDg”就是初始密码(不含首位空格)根据实际生成,请牢记,后面登录需要
3.2 安装服务
在MySQL安装目录的 bin 目录下执行命令:
mysqld --install [服务名](服务名可以不加默认为mysql)
D:\Lenovo\MySQL\bin>mysqld --install
Service successfully installed.
服务安装成功之后
通过命令net start mysql启动MySQL的服务
通过命令net stop mysql启动MySQL的服务
通过命令sc delete MySQL/mysqld -remove卸载 MySQL 服务
4.进入mysql
无密码进入
mysql -u root
或有密码进入
mysql -u root -p
初始密码为步骤3中root@localhost:后面的“字符串“
D:\Lenovo\MySQL\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.16
Copyright (c) 2000, 2019, 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.
mysql>
5、更改密码
在MySQL中执行命令:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
修改密码为123(可自行设定),注意命令尾的;一定要有,这是mysql的语法
6、mysql退出:mysql > exit;
mysql退出三种方法:
mysql > exit;
mysql > quit;
mysql > \q;
7、数据库图形化工具Navicat
分享一个免安装的Navicat Premium 12
链接:https://pan.baidu.com/s/1TrPYBOU8APWlarFW_QTLlQ密码:7jbs
我们的MySQL的服务已经开启了就直接打开的Navicat去连接!
新建的MySQL的连接
输入步骤5修改后的密码
测试一下!
MySQL的是成功安装了也可以登录
参考:
https://blog.csdn.net/qq_37350706/article/details/81707862