1.说明(本人win10系统)
起初本人使用的mysql5.6.26版本,后期发现导入sql文件老报错(某某某unsuccessful),于是选择安装5.7.31,看了网上好多的文章,最终打算把自己的安装过程记录一下.
2.安装包链接 :
链接:https://pan.baidu.com/s/1l7njWHk_zmnwQCRevyF1Ow
提取码:2r3l
当然也可以自己去官网下载一个,即安全又放心.
3.彻底干掉以前电脑中的mysql
3.1 右击我的电脑-管理-服务,找到mysql右击停止
3.2 右击我的电脑-属性-控制面板-卸载程序-如果有mysql的话删除即可
3.3 cmd中输入sc delete mysql
3.4 找到你之前安装mysql的位置,进行删除.例如下面是我的位置
3.5 删除注册表信息,cmd中输入regedit敲回车
在出现的页面中找到以下两个位置对mysql文件进行删除,如果存在的话.
\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\eventlog\Application\MySQL
\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\services\eventlog\Application\MySQL
4.安装新的mysql
4.1 将压缩包解压后,添加一个my.ini文件到解压后的文件下,只需把basedir,datadir,Server三处根据自己放的位置修改下就可以.
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 = "D:\AOffice\Mysql\mysql-5.7.31-winx64"
datadir = "D:\AOffice\Mysql\mysql-5.7.31-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
#设置数据库引擎为INNODB
default-storage-engine=INNODB
# 设置mysql服务器编码
character_set_server=utf8
# 设置mysql服务器字符集
collation-server=utf8_general_ci
port = 3306
server_id = 1
[client]
default-character-set = utf8
[WinMySQLAdmin]
Server = "D:\AOffice\Mysql\mysql-5.7.31-winx64\bin\mysqladmin.exe"
4.2 设置环境变量,我的电脑-属性-高级系统设置-环境变量-系统变量
4.3 window+r,输入cmd后,ctrl+shift+回车,及进入管理员运行,进入到bin目录下,输入mysqld --install
注:假如报错丢失MSVCP120.dll
https://www.microsoft.com/zh-CN/download/details.aspx?id=40784
下载64位(假如是64位的话),默认安装地址即可解决
4.4 输入mysqld --initialize
4.5 输入net start mysql
5.修改mysql密码
5.1 查看初始密码,在data文档中,有个err后缀的文件,里面有初始密码,红框那个位置
5.2 输入mysql -uroot -p回车后输入初始密码进行登陆
5.3 登陆后输入以下语句进行密码修改
alter user "root"@"localhost" identified by "你要修改的密码";
5.4 使用本地各种软件(Navicat,sqlyog…)进行数据库连接就可以了.