Mysql数据库版本升级5.5—5.7

  • Post author:
  • Post category:mysql


mysql版本升级,主要分为一下阶段:


1、数据库数据备份


2、mysql删除(一定要完全删干净)


3、新版本Mysql安装

查看自己数据库版本,打开cmd,输入命令


  1. 关闭Mysql服务。

    在服务里找到Mysql,右键停止服务,点开属性,查看mysql安装路径


2、数据库备份

通过上面的路径,找到数据库文件存放位置,在mysql文件夹下面,找到一个名为my.ini的文件,打开,找到datadir,可以看到数据文件放在了哪里。

通过数据文件存放位置路径(datadir)找到数据文件

把data文件拷贝一份,先放到别的地方


3、完全卸载mysql

管理员身份打开cmd,输入命令:mysqld -remove。移除现有mysql服务

删除mysql安装文件夹

删除mysql的数据文件夹

卸载Mysql相关注册表

Win+R,然后输入regedit,打开注册表

删除注册表中的mysql文件。如果删除不干净会影响后续安装新版mysql。

找到下面路径中(ControlSet001文件夹下面)的mysql文件夹,删除

以及ControlSet002文件夹、CurrentControlSet文件夹,如果里面有mysql文件,都删除。


安装新版本Mysql

打开mysql官网,在download页面,找到自己需要下载的版本

把下载好的压缩包解压到自己需要放置的路径下,我这里还是把文件放到之前的路径下D:\Program Files\mysql

配置环境变量

打开此电脑—-鼠标右键—属性

高级系统设置

系统变量—编辑环境变量—新建

把Mysql文件打开,一直到bin目录下,把地址复制粘贴到里面,然后保存。

在Mysql文件夹下面新建一个my.ini文件

内容如下

# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
 
port=3306
 
[mysql]
 
default-character-set=utf8
 
 
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
 
# The TCP/IP Port the MySQL Server will listen on
port=3306
 
 
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/mysql/mysql-5.7.40-winx64"
 
#Path to the database root
datadir="D:/Program Files/mysql/mysql-5.7.40-winx64/data"
 
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
 
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
 
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
 
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=100
 
# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=0
 
# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_open_cache=256
 
# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=35M
 
 
# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=8
#*** MyISAM Specific options
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G
# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=69M
# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=55M
 
# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K
 
# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K

其中需要改的地方:其中这两处改成自己的地址。

把刚刚备份的data文件夹放到安装地址位置这个地址下。

如下图:

重启mysql

进入cmd,以管理员方式打开。

输入命令

启动服务,进入数据库,此时版本号已经变为5.7

mysql就升级成功了!!!



版权声明:本文为qq_42461481原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。