一直以来都习惯了我们使用MySQL安装文件(.exe),这样一键式的非常方便,也省去好多麻烦,因为我是搞编程的,习惯自己动手,所有我写个zip解压时的MYSQL 安装。下面以mysql-8.0.15.zip为例
操作系统
安装包
- 在MySQL官网上(http://dev.mysql.com/downloads/mysql/)下载免安装版的zip文件
- mysql-8.0.15-winx64.zip
安装步骤
- 下载mysql-8.0.15-winx64.zip包,可以通过上面2种方式获取。
- 将mysql-8.0.15-winx64.zip文件解压到本地,本文解压到如下目录:F:\SP\mysql-8.0.15
- 解压之后,在F:\SP\mysql-8.0.15下有个my-default.ini的文件,进行复制一个出来改名为my.ini。(如果解压包中没有,你要新建一个my.ini)。注意:这个文件必须要在该目录下,不过在8.0.15的版本里没有该文件,在8.0.11的版本里有,不过我这边是新建的my.ini的文件。
- 接下来就是修改my.ini,把下面的代码复制到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.
[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
修改红色的内容,记得路径不要写错哦,还有记得在目录下建个data文件,该文件夹用来存放数据的。
6. 输入cmd,以管理员身份运行控制台,进入MySQL路径(F:\SP\mysql-8.0.15\bin)下,运行mysqld --initialize --console命令。进行初始化,如下:
** 注意红色部分是密码啊,要记住哦!**
7. 输入cmd,以管理员身份运行控制台,进入MySQL路径(F:\SP\mysql-8.0.15\bin)下,运行mysqld install命令。安装成功后如下:
** 注意:这里需要以管理员身份运行,否则提示如下:**
8. 启动服务,net start mysql 如下
9. 接下来就是修改密码啦!毕竟生成的密码不好记!mysql -uroot -p,输入上面生成的密码!
10. 接下来输入sql 语句
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
- 如果想默认使用“mysql_native_password”插件认证,可以在配置文件中配置default_authentication_plugin项。
[mysqld]
default_authentication_plugin=mysql_native_password
大功告成啦!是不是自己动手起来很复杂,不好弄啊!只要细心,基本都是成功的!本次测试是:mysql-8.0.15.zip的版本