MySQL安装教程
- 2019 年 10 月 6 日
- 筆記
完美的MySQL安装教程,再装不好,我给你装去!!!!

首先,把压缩包给你们:
链接:https://pan.baidu.com/s/1eKcAUi0ICyOG60XyS8PkDw 密码:xacu
一 把文件解压到一个目录下


这是解压后的目录

新建一个my.ini文件,复制如下内容:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = C:Usersyuqing.wuDesktopmysql-5.7.20-winx64
datadir = C:Usersyuqing.wuDesktopmysql-5.7.20-winx64data
port = 3306
# server_id = …..
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
把蓝色的两行更改成自己的解压路径保存
将my.ini文件copy进解压目录

右键此电脑属性

找到高级系统设置配置环境变量


新建—》变量值是解压文件的路径

Path 单击path 编辑


新建

之后 用管理员身份打开cmd 进入文件路径

打开命令行窗口,在里面输入:mysqld –install

这个命令是安装服务, 执行完后,提示英文的成功, 这时候你可以在你的 windows 服务中看到 MySQL 的服务,移除服务命令为:mysqld remove
接着输入:mysqld –initialize –console
执行这一步,是因为在MySQL5.7中没有data文件夹,需要用这几个命令产生data文件夹,并且初始化随机登陆密码
执行完会出现一大片英文,看不懂没关系,在最后面看到有一个root@localhost: 后面有一连串的字母数字符号, 这是MySQL 为你自动生成的随机密码. 要记下来, root就是登陆的用户名,一会我们登陆 MySQL 数据库的时候要用

4.启动mysql服务
在安装后只有启动了mysql服务才能用,方式有2个
命令行输入:net start mysql

5.修改默认密码
之前系统随机生成的密码只能用来登陆,然后修改密码,用不了mysql,只有修改了才能用
启动了mysql服务后
命令行输入:mysql -uroot –p

然后会提示要输入密码,就是之前生成的密码
登陆成功就是上图了,直接输入:SET PASSWORD =PASSWORD('你的新密码');

至此mysql已经全部安装配置完成了,可以直接用了,如图,可以查看原有的那些数据库
至此,祝使用愉快!