溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MySQL5.6.30如何升級(jí)到MySQL5.7.18

發(fā)布時(shí)間:2021-11-25 10:56:04 來(lái)源:億速云 閱讀:97 作者:小新 欄目:數(shù)據(jù)庫(kù)

這篇文章給大家分享的是有關(guān)MySQL5.6.30如何升級(jí)到MySQL5.7.18的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

本次升級(jí)采用:out of place 邏輯升級(jí)方式:

基本步驟:
①:停止業(yè)務(wù),備份現(xiàn)有數(shù)據(jù)庫(kù)(mysqldump方式或者物理備份)
②:下載MySQL5.7.18軟件包,然后安裝到別的目錄,
③:修改配置my.cnf配置文件,指定basedir為新的軟件目錄
④:?jiǎn)?dòng)新版本數(shù)據(jù)庫(kù),然后執(zhí)行mysql_upgrade -uroot -p 升級(jí)數(shù)據(jù)庫(kù);
⑤:升級(jí)完成,重啟數(shù)據(jù)庫(kù)
⑥:檢查升級(jí)結(jié)果:select version();

升級(jí)MySQL檢查:
①:現(xiàn)有MySQL數(shù)據(jù)庫(kù)是否已經(jīng)備份
②:業(yè)務(wù)是否已經(jīng)停止

1、檢查現(xiàn)有環(huán)境:
①:檢查MySQL狀態(tài):
[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

②:查看現(xiàn)有配置文件
[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

③:檢查現(xiàn)有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>

④:關(guān)閉數(shù)據(jù)庫(kù):
[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參數(shù)解釋:
關(guān)閉:innodb_fast_shutdown=
0 :完成所有的full purge和merge insert buffer操作(如:做InnoDB plugin升級(jí)時(shí))
1 :默認(rèn),不需要完成上述操作,但會(huì)刷新緩沖池中的臟頁(yè)
2 :不完成上述兩個(gè)操作,而是將日志寫(xiě)入日志文件,下次啟動(dòng)時(shí),會(huì)執(zhí)行恢復(fù)操作recovery
沒(méi)有正常地關(guān)閉數(shù)據(jù)庫(kù)(如:kill命令)/innodb_fast_shutdown=2時(shí),需要進(jìn)行恢復(fù)操作。


2、下載mysql5.7.18,并且解壓到新目錄
mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz     (這個(gè)軟件包解壓后就可以用,不用安裝)
[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這個(gè)就是新的軟件目錄)

3、修改配置文件:my.cnf
[mysql@db2 mysql5718]$ cp /mysql/my.cnf ./
[mysql@db2 mysql5718]$ vim my.cnf
basedir                   = /home/mysql/mysql5718/     -----只需要修改這一行就可以,指向新目錄

4、使用新軟件啟動(dòng)MySQL數(shù)據(jù)庫(kù):
[mysql@db2 mysql5718]$ /home/mysql/mysql5718/bin/mysqld_safe --defaults-file=/home/mysql/mysql5718/my.cnf --socket=/mysql/data/mysql.sock &

5、升級(jí)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.

出現(xiàn)上述信息,就表明MySQL升級(jí)完成了;

6、升級(jí)完成后,重啟數(shù)據(jù)庫(kù)
[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、登錄數(shù)據(jù)庫(kù)檢查升級(jí)狀態(tài):
[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)
有時(shí)候我們登錄MySQL的時(shí)候會(huì)出現(xiàn)上面的錯(cuò)誤,可是我們已經(jīng)在配置文件指定了mysql.sock的目錄呀,為什么還去找別的目錄呢,解決方法有兩種:
第一在my.cnf配置文件添加下面的信息:(有時(shí)候不管用,比如我們上面的配置文件已經(jīng)添加了可是還是報(bào)錯(cuò))
[mysql]
socket                    = /mysql/data/mysql.sock

第二種:我們做個(gè)軟連接到tmp下就可以了:
[mysql@db2 bin]$ ln -s /mysql/data/mysql.sock /tmp/mysql.sock
做完軟連接后,我們?cè)俚攘藬?shù)據(jù)庫(kù)就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>

######################################################################

知識(shí)擴(kuò)展:
關(guān)閉:innodb_fast_shutdown=

0 :完成所有的full purge和merge insert buffer操作(如:做InnoDB plugin升級(jí)時(shí))
1 :默認(rèn),不需要完成上述操作,但會(huì)刷新緩沖池中的臟頁(yè)
2 :不完成上述兩個(gè)操作,而是將日志寫(xiě)入日志文件,下次啟動(dòng)時(shí),會(huì)執(zhí)行恢復(fù)操作recovery
    沒(méi)有正常地關(guān)閉數(shù)據(jù)庫(kù)(如:kill命令)/innodb_fast_shutdown=2時(shí),需要進(jìn)行恢復(fù)操作。

恢復(fù):innodb_force_recovery=

0 :默認(rèn),但需要恢復(fù)時(shí)執(zhí)行所有恢復(fù)操作
1 :忽略檢查到的corrupt頁(yè)
2 :阻止主線程的運(yùn)行,如主線程需要執(zhí)行full purge操作,會(huì)導(dǎo)致crash
3 :不執(zhí)行事務(wù)回滾操作
4 :不執(zhí)行插入緩沖的合并操作
5 :不查看撤銷(xiāo)日志undo log,InnoDB存儲(chǔ)引擎會(huì)將所有未提交的事務(wù)視為已提交
6 :不執(zhí)行前滾的操作

感謝各位的閱讀!關(guān)于“MySQL5.6.30如何升級(jí)到MySQL5.7.18”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI