mysql安装

1.地址:https://dev.mysql.com/downloads/

2.进入后点击以下步骤:

​ (1).点击 mysql Community Server(MySQL社区版)

​ (2).查看 Select Operating System: 下可以选择本机系统,默认Windows系统,Other Downloads: 下选择MySQL安装包点击 Downloads下载,

3.将安装包解压到自己的目录,进入文件夹,在和bin同目录下创建个data目录,再创建个mysql.ini文件

4.向mysql.ini文件里面添加以下内容:

[mysql]

# 设置mysql客户端默认字符集
default-character-set=utf8 

[mysqld]

#设置3306端口
port = 3306 

# 设置mysql的安装目录
basedir=F:\mysql\mysql-5.7.24-winx64\mysql-5.7.24-winx64

# 设置mysql数据库的数据的存放目录
datadir=F:\mysql\mysql-5.7.24-winx64\mysql-5.7.24-winx64\data

# 允许最大连接数
max_connections=200

# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

5.以管理员运行cmd,进入MySQL的bin目录

Microsoft Windows [版本 10.0.18363.1379]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\WINDOWS\system32>cd C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin

C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin>mysqld --install
Service successfully installed.

C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin>mysqld --initialize --console  //安装MySQL
2021-03-09T02:08:00.902820Z 0 [System] [MY-013169] [Server] C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin\mysqld.exe (mysqld 8.0.23) initializing of server in progress as process 14588
2021-03-09T02:08:00.932888Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-03-09T02:08:01.611207Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-03-09T02:08:03.072702Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .)Gs><ov_7Gr      //出现密码,要记住

C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin>net start mysql    //启动服务
MySQL 服务正在启动 .
MySQL 服务已经启动成功。


C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin>mysql -u root -p    //登录MySQL
Enter password: ************      //密码,刚才上面需要记住的密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.23

Copyright (c) 2000, 2021, 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> alter user 'root'@'localhost' identified by '123456';    //开头出现“mysql>”表示成功,此处就来修改密码
Query OK, 0 rows affected (0.01 sec)

mysql> exit    //成功后退出
Bye

C:\Users\1\Desktop\DownloadSoftware\mysql\sqloftware\mysql-8.0.23-winx64\bin>mysql -u root -p      //用修改的密码再次登录sql看能否成功
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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>      //成功

//完成!!!

参考博客:https://www.cnblogs.com/winton-nfs/p/11524007.html

上一篇:Mysql 5.7.28离线包下载与配置


下一篇:Windows下安装MySQL详细教程