这篇文章给大家分享的是有关Mysql5.6.30如何升级到mysql5.7.18的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。本次升级采用:out of place 逻辑升级方式
这篇文章给大家分享的是有关Mysql5.6.30如何升级到mysql5.7.18的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
本次升级采用:out of place 逻辑升级方式:
基本步骤:
①:停止业务,备份现有数据库(mysqldump方式或者物理备份)
②:下载MySQL5.7.18软件包,然后安装到别的目录,
③:修改配置my.cnf配置文件,指定basedir为新的软件目录
④:启动新版本数据库,然后执行mysql_upgrade -uroot -p 升级数据库;
⑤:升级完成,重启数据库
⑥:检查升级结果:select version();
升级MySQL检查:
①:现有MySQL数据库是否已经备份
②:业务是否已经停止
1、检查现有环境:
①:检查MySQL状态:
[mysql@db2 ~]$ ps -ef | grep mysql
mysql 1806 1 0 14:36 ? 00:00:00 /bin/sh /mysql/bin/mysqld_safe --defaults-file=/mysql/my.cnf
mysql 1868 1806 0 14:36 ? 00:00:00 /mysql/bin/mysqld --defaults-file=/mysql/my.cnf --basedir=/mysql --datadir=/mysql/data --plugin-dir=/mysql/lib/plugin --log-error=/mysql/data/db2.err --pid-file=/mysql/data/db2.pid
②:查看现有配置文件
[mysql@db2 ~]$ vim /mysql/my.cnf
[mysql]
no_auto_rehash
default_character_set = utf8
Socket = /mysql/data/mysql.sock
[client]
default_character_set = utf8
[mysqld]
server_id = 1607
port = 3306
basedir = /mysql/
datadir = /mysql/data/
socket = /mysql/data/mysql.sock
pid_file = /mysql/data/mysql.pid
log_error = /mysql/data/mysql_error.log
log_bin = /mysql/data/mysql_bin
relay_log = /mysql/data/relay_bin
character_set_server = utf8
collation_server = utf8_general_ci
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 1G
innodb_log_files_in_group = 3
innodb_log_buffer_size = 24M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_io_capacity = 200
innodb_io_capacity_max = 600
innodb_thread_concurrency = 0
innodb_autoinc_lock_mode = 2
innodb_lock_wait_timeout = 60
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_max_dirty_pages_pct = 80
innodb_autoextend_increment = 512
innodb_checksum_alGorithm = NONE
innodb_doublewrite = 0
innodb_use_native_aio = 1
innodb_open_files = 8192
sync_binlog = 1
sync_relay_log = 1
relay_log_info_repository = TABLE
master_info_repository = TABLE
expire_logs_days = 10
binlog_fORMat = ROW
transaction-isolation = READ-COMMITTED
concurrent_insert = 2
skip_slave_start = TRUE
back_log = 2000
thread_stack = 256k
thread_cache_size = 256
key_buffer_size = 256M
tmp_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 2M
join_buffer_size = 2M
query_cache_size = 0
query_cache_type = 0
max_heap_table_size = 64M
binlog_cache_size = 2M
table_open_cache = 8192
max_allowed_packet = 64M
bulk_insert_buffer_size = 64M
max_connect_errors = 100000
max_connections = 500
connect_timeout = 300
wait_timeout = 86400
interactive_timeout = 86400
lower_case_table_names = 1
open_files_limit = 20480
skip_name_resolve
skip_external_locking
explicit_defaults_for_timestamp = TRUE
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
③:检查现有MySQL的版本信息:
[mysql@db2 ~]$ mysql -u root -p
Enter passWord:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.30 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \s
--------------
mysql Ver 14.14 Distrib 5.6.30, for linux (x86_64) using EditLine wrapper
Connection id: 6
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.30 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 5 min 32 sec
Threads: 1 Questions: 18 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.054
--------------
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.30 |
+-----------+
1 row in set (0.01 sec)
mysql>
④:关闭数据库:
[mysql@db2 ~]$ mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
Enter password:
[mysql@db2 ~]$ mysql -u root -p --execute="show global variables like 'innodb_fast_shutdown'"
Enter password:
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| innodb_fast_shutdown | 0 |
+----------------------+-------+
[mysql@db2 ~]$ mysqladmin -uroot -p shutdown
Enter password:
注意:innodb_fast_shutdown参数解释:
关闭:innodb_fast_shutdown=
0 :完成所有的full purge和merge insert buffer操作(如:做InnoDB plugin升级时)
1 :默认,不需要完成上述操作,但会刷新缓冲池中的脏页
2 :不完成上述两个操作,而是将日志写入日志文件,下次启动时,会执行恢复操作recovery
没有正常地关闭数据库(如:kill命令)/innodb_fast_shutdown=2时,需要进行恢复操作。
2、下载mysql5.7.18,并且解压到新目录
mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz (这个软件包解压后就可以用,不用安装)
[mysql@db2 ~]$ tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz (把软件直接解压到/home/mysql)
[mysql@db2 ~]$ mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql5718 (mysql5718这个就是新的软件目录)
3、修改配置文件:my.cnf
[mysql@db2 mysql5718]$ cp /mysql/my.cnf ./
[mysql@db2 mysql5718]$ vim my.cnf
basedir = /home/mysql/mysql5718/ -----只需要修改这一行就可以,指向新目录
4、使用新软件启动MySQL数据库:
[mysql@db2 mysql5718]$ /home/mysql/mysql5718/bin/mysqld_safe --defaults-file=/home/mysql/mysql5718/my.cnf --socket=/mysql/data/mysql.sock &
5、升级MySQL:
[mysql@db2 mysql5718]$ /home/mysql/mysql5718/bin/mysql_upgrade -uroot -p --socket=/mysql/data/mysql.sock
Enter password:
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL Server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Upgrading the sys schema.
Checking databases.
sys.sys_config OK
Upgrade process completed successfully.
Checking if update is needed.
出现上述信息,就表明MySQL升级完成了;
6、升级完成后,重启数据库
[mysql@db2 mysql5718]$ /home/mysql/mysql5718/bin/mysqladmin shutdown -u root -p
[mysql@db2 mysql5718]$ /home/mysql/mysql5718/bin/mysqld_safe --defaults-file=/home/mysql/mysql5718/my.cnf --socket=/mysql/data/mysql.sock &
7、登录数据库检查升级状态:
[mysql@db2 bin]$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
有时候我们登录MySQL的时候会出现上面的错误,可是我们已经在配置文件指定了mysql.sock的目录呀,为什么还去找别的目录呢,解决方法有两种:
第一在my.cnf配置文件添加下面的信息:(有时候不管用,比如我们上面的配置文件已经添加了可是还是报错)
[mysql]
socket = /mysql/data/mysql.sock
第二种:我们做个软连接到tmp下就可以了:
[mysql@db2 bin]$ ln -s /mysql/data/mysql.sock /tmp/mysql.sock
做完软连接后,我们再等了数据库就OK了:
[mysql@db2 bin]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log MySQL CommUnity Server (GPL)
Copyright (c) 2000, 2016, oracle and/or its affiliates. All rights reserved.
Oracle is a reGIStered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \s
--------------
mysql Ver 14.14 Distrib 5.6.30, for Linux (x86_64) using EditLine wrapper
Connection id: 3
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 4 min 16 sec
Threads: 1 Questions: 6 Slow queries: 0 Opens: 110 Flush tables: 1 Open tables: 25 Queries per second avg: 0.023
--------------
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.18-log |
+------------+
1 row in set (0.39 sec)
mysql>
######################################################################
知识扩展:
关闭:innodb_fast_shutdown=
0 :完成所有的full purge和merge insert buffer操作(如:做InnoDB plugin升级时)
1 :默认,不需要完成上述操作,但会刷新缓冲池中的脏页
2 :不完成上述两个操作,而是将日志写入日志文件,下次启动时,会执行恢复操作recovery
没有正常地关闭数据库(如:kill命令)/innodb_fast_shutdown=2时,需要进行恢复操作。
恢复:innodb_force_recovery=
0 :默认,但需要恢复时执行所有恢复操作
1 :忽略检查到的corrupt页
2 :阻止主线程的运行,如主线程需要执行full purge操作,会导致crash
3 :不执行事务回滚操作
4 :不执行插入缓冲的合并操作
5 :不查看撤销日志undo log,InnoDB存储引擎会将所有未提交的事务视为已提交
6 :不执行前滚的操作
感谢各位的阅读!关于“MySQL5.6.30如何升级到MySQL5.7.18”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
--结束END--
本文标题: MySQL5.6.30如何升级到MySQL5.7.18
本文链接: https://lsjlt.com/news/67191.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0