解压版MySQL安装与卸载教程

MySQL分为安装版和解压版。安装版经常安装失败,重新安装需要卸载MySQL,十分麻烦,推荐解压版MySQL。

详细步骤如下:

1.下载

官网下载网址:MySQL :: Download MySQL Community Server

根据你的系统(32位或者64位)选择后缀是ZIP Archive的压缩包下载到本地,这里我下载的是“MySQL5.7.13

点击Dowload后会要求你登录,不用管,直接点击No thanks, just start my download。

2.解压

MySQL5.7.13的解压后的内容如下,解压后将文件重命名为MySQL,放在D\software目录下:

3.配置my.ini

此时根目录下只有一个my-default.ini文件 ,直接复制my-default.ini,重命名为my.ini,再对my.ini进行修改。

原始的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 = .....
# datadir = .....
# port = .....
# 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 

修改后的内容为:

# 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.

[mysql]
 default-character-set = utf8

[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:\\software\\MySQL
datadir = D:\\software\\MySQL\\data
port = 3306
# server_id = .....


max_connections=200
character-set-server=utf8
default_authentication_plugin=mysql_native_password
default-storage-engine=INNODB
wait_timeout=31536000
interactive_timeout=31536000


# 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]
#设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]
#设置3306端口
port=3306
#设置mysql的安装目录
basedir = D:\\software\\MySQL
#设置mysql数据库的数据的存放目录
datadir = D:\\software\\MySQL\\data

#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#更改8.0默认的身份认证
default_authentication_plugin=mysql_native_password
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
wait_timeout=31536000
interactive_timeout=31536000

注意: 这里的路径是双下划线“\\”,否则在后面安装时会报错

    basedir = D:\\software\\MySQL

   datadir = D:\\software\\MySQL\\data

4.配置环境变量。

右键计算机–属性–高级系统设置–环境变量,在系统变量中新建“MYSQL_HOME”,值为“D:\software\MySQL”。

在系统变量中找到Path编辑,追加“D:\software\MySQL\bin”。(这里最好写MySQL具体的安装路径)

 

5.初始化。

以管理员身份运行cmd

首先切换到D:\software\MySQL\bin目录下:

d:
cd D:\software\MySQL\bin

 在MySQL目录下的bin目录下执行命令:

mysqld --initialize-insecure

回车,稍微等待一会,如果出现没有出现报错信息(如下图)则证明data目录初始化没有问题,此时再查看MySQL目录下已经有data目录生成。

6.注册MySQL服务

继续在上面的黑框里,敲入mysqld -install,回车。

7.启动MySQL服务

关闭cmd窗口,重新打开一个新的,使用管理员运行cmd。

输入如下内容,回车。

net start mysql

8.修改默认账户密码

在黑框里敲入mysqladmin -u root password root,这里的root就是指默认管理员(即root账户)的密码,可以自行修改成你喜欢的。

至此,MySQL 5.7 解压版安装完毕!


9.登录MySQL

关闭所有的cmd窗口,重新运行cmd(不用使用管理员运行)

在黑框中输入,mysql -uroot -proot,回车,出现下图且左下角为mysql>,则登录成功。

到这里你就可以开始你的MySQL之旅了!


10.卸载MySQL

如果你想卸载MySQL,也很简单。

使用管理员运行cmd,打开黑框。

敲入net stop mysql,回车。

再敲入mysqld -remove mysql,回车。

最后删除MySQL目录及相关的环境变量。

至此,MySQL卸载完成!

参考:

MySQL 5.7 解压版 安装教程(图文详细)[Windows] - Horvey - 博客园

MySQL 8.0.20安装教程(Win10)—— 免安装版_saltedfishust的博客-CSDN博客_mysql8.0.20

https://www.jb51.net/article/170127.htm

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值