您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關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”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。