MySQL5.7.24压缩包安装教程

MySQL安装包下载:
https://dev.mysql.com/downloads/mysql/

根据需要下载对应版本MySQL

接下来,点击Download,选择No thanks, just start my download就会直接下载安装包。

二:配置环境变量
新建MYSQL_HOME变量,变量名为你的解压路径名

编辑path变量,在末尾加上 ;%MYSQL_HOME%\bin;

三:解压安装包到指定路径-------my.ini文件
1. 下载完成后解压到你想要放的目录(5.7.20左右的版本(至少5.7.20是),没my-default.ini这个文件了)

2. 在bin的同级目录,新建my-default.ini文件。我的ini文件是这样的:

[mysqld]
port = 3306
basedir=D:\tools\mysql-5.7.24-winx64  //mysql安装目录
datadir=D:\tools\mysql-5.7.24-winx64/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8
 

3. 在bin目录下面,新建(或者复制my-default.ini)my.ini文件,不然初始化mysqld --initialize-insecure, data文件会报找不到文件夹(不能自动生成data文件夹)

我的my.ini:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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.

[mysqld]

# 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 = D:\tools\mysql-5.7.24-winx64  //mysql安装目录
datadir = D:\tools\mysql-5.7.24-winx64\data
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 = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 

四:安装MySQL服务以及初始化


以管理员身份运行cmd,

以下所有命令都需要进入到mysql安装目录的bin目录下进行!!!

执行安装mysql服务的命令:mysqld --install

mysqld --install


我们可以看到服务已经成功安装。

假设这里出现安装不成功,那么就有可能是你之前安装了但是卸载不完全导致的,所以一定要卸载完整。

完全卸载mysql教程:https://blog.csdn.net/hcrw01/article/details/84261749

初始化MySQL:

   mysqld --initialize

初始化完成后会出现data文件夹

如果有data文件夹了,先删除掉,再执行mysqld --initialize.


然后启动MySQL:

    net start mysql

MySQL登录:mysql -u root -p

注意:初始密码可以在生成的data文件夹下后缀名为.err的文件

然后设置自己的登录密码:

alter user user() identified by "你的新密码";

 mysql>FLUSH PRIVILEGES; //刷新权限
 

猜你喜欢

转载自blog.csdn.net/hcrw01/article/details/84262062