<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • MySQL5.6.25升級(jí)MySQL5.7.15

            MySQL5.6.25升級(jí)MySQL5.7.15

            創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),鼓樓企業(yè)網(wǎng)站建設(shè),鼓樓品牌網(wǎng)站建設(shè),網(wǎng)站定制,鼓樓網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,鼓樓網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

            MySQL5.6升級(jí)MySQL5.7

            環(huán)境介紹

            Part1:寫在最前

            提到MySQL升級(jí),網(wǎng)上文章數(shù)之不盡,但大多數(shù)為老的版本,諸如5.1升級(jí)到5.5、5.5升級(jí)到5.6,今天給大家介紹下MySQL5.6升級(jí)到MySQL5.7版本的方法和注意事項(xiàng)。

            Part2:升級(jí)方法

            升級(jí)的方法一般有兩類:

            1.利用mysqldump來直接導(dǎo)出sql文件,導(dǎo)入到新庫中,這種方法是最省事兒的,也是最保險(xiǎn)的,缺點(diǎn)的話,也顯而易見,大庫的mysqldump費(fèi)時(shí)費(fèi)力。

            2.直接替換掉mysql的安裝目錄和my.cnf,利用mysql_upgrade 來完成系統(tǒng)表的升級(jí),這種方法需要備份原有的文件,但屬于物理拷貝,速度較快。缺點(diǎn)的話,跨版本升級(jí)不推薦這么做,比如mysql5.1升級(jí)到mysql5.6,mysql5.5升級(jí)到mysql5.7等。

            本文采用的是第二種方法升級(jí)。

            Part3:環(huán)境

            數(shù)據(jù)庫軟件目錄:/usr/local/mysql

            my.cnf位置:/etc/my.cnf

            數(shù)據(jù)庫data目錄:/data/mysql

            慢日志目錄:/data/slowlog

            準(zhǔn)備工作

            Part1:MySQL5.6.25

            [root@HE3 ~]# mysql -uroot -p
            Enter password: 
            Welcome to the MySQL monitor.  Commands end with ; or \g.
            Your MySQL connection id is 1
            Server version: 5.6.25-log MySQL Community Server (GPL)
            Copyright (c) 2000, 2015, 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> select version();
            +------------+
            | version()  |
            +------------+
            | 5.6.25-log |
            +------------+
            1 row in set (0.00 sec)
            mysql> use helei;
            Database changed
            mysql> show tables;
            +-----------------+
            | Tables_in_helei |
            +-----------------+
            | helei           |
            +-----------------+
            1 row in set (0.00 sec)

            我這里用的是5.6.25版本作為待升級(jí)庫,庫中已經(jīng)模擬和創(chuàng)建了數(shù)據(jù)庫helei和表helei,用以之后驗(yàn)證升級(jí)。

            Part2:備份

            備份整體需要備份的是my.cnf、數(shù)據(jù)庫安裝目錄、還有數(shù)據(jù)目錄。

            [root@HE3 ~]# /etc/init.d/mysqld stop

            Shutting down MySQL.. SUCCESS! 

            [root@HE3 etc]# cp -rp my.cnf my_56_old.cnf

            [root@HE3 local]# cp -rp mysql mysql_56_old

            [root@HE3 ~]# rm -rf /usr/local/mysql

            [root@HE3 data]# cp -rp mysql/ mysql_56_old

            這里我直接采用cp的方式來進(jìn)行。

            Part3:替換

            1.替換/etc/my.cnf為mysql5.7的my.cnf

            [root@HE3 ~]#vi /etc/my.cnf
            [client]
            port=3306
            socket=/tmp/mysql.sock
            default-character-set=utf8
            [mysql]
            no-auto-rehash
            default-character-set=utf8
            [mysqld]
            port=3306
            character-set-server=utf8
            socket=/tmp/mysql.sock
            basedir=/usr/local/mysql
            datadir=/data/mysql
            explicit_defaults_for_timestamp=true
            lower_case_table_names=1
            back_log=103
            max_connections=3000
            max_connect_errors=100000
            table_open_cache=512
            external-locking=FALSE
            max_allowed_packet=32M
            sort_buffer_size=2M
            join_buffer_size=2M
            thread_cache_size=51
            query_cache_size=32M
            #query_cache_limit=4M
            transaction_isolation=REPEATABLE-READ
            tmp_table_size=96M
            max_heap_table_size=96M
            ###***slowqueryparameters
            long_query_time=1
            slow_query_log = 1
            slow_query_log_file=/data/slowlog/slow.log
            ###***binlogparameters
            log-bin=mysql-bin
            binlog_cache_size=4M
            max_binlog_cache_size=8M
            max_binlog_size=1024M
            binlog_format=MIXED
            expire_logs_days=7
            ###***relay-logparameters
            #relay-log=/data/3307/relay-bin
            #relay-log-info-file=/data/3307/relay-log.info
            #master-info-repository=table
            #relay-log-info-repository=table
            #relay-log-recovery=1
            #***MyISAMparameters
            key_buffer_size=16M
            read_buffer_size=1M
            read_rnd_buffer_size=16M
            bulk_insert_buffer_size=1M
            #skip-name-resolve
            ###***master-slavereplicationparameters
            server-id=$SERVERID
            slave-skip-errors=all
            #***Innodbstorageengineparameters
            innodb_buffer_pool_size=512M
            innodb_data_file_path=ibdata1:10M:autoextend
            #innodb_file_io_threads=8
            innodb_thread_concurrency=16
            innodb_flush_log_at_trx_commit=1
            innodb_log_buffer_size=16M
            innodb_log_file_size=512M
            innodb_log_files_in_group=2
            innodb_max_dirty_pages_pct=75
            innodb_buffer_pool_dump_pct=50
            innodb_lock_wait_timeout=50
            innodb_file_per_table=on
            innodb_buffer_pool_dump_at_shutdown=1
            innodb_buffer_pool_load_at_startup=1
            sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
            [mysqldump]
            quick
            max_allowed_packet=32M
            [myisamchk]
            key_buffer=16M
            sort_buffer_size=16M
            read_buffer=8M
            write_buffer=8M
            [mysqld_safe]
            open-files-limit=8192
            log-error=/data/mysql/error.log
            pid-file=/data/mysql/mysqld.pid

            2.解壓新版mysql

            [root@HE3 ~]# tar xvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 

            [root@HE3 ~]# mv mysql-5.7.15-linux-glibc2.5-x86_64 /usr/local/mysql

            [root@HE3 ~]# chown -R mysql. /usr/local/mysql

            3.替換新版mysqld啟動(dòng)腳本

            [root@HE3 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

            cp: overwrite `/etc/init.d/mysqld'? y

            開始升級(jí)

            Part1:啟動(dòng)

            [root@HE3 ~]# /etc/init.d/mysqld start
            Starting MySQL..... SUCCESS! 
            [root@HE3 ~]# ps -ef|grep mysql
            root     26467     1  0 20:30 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/HE3.pid
            mysql    27197 26467  4 20:30 pts/2    00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/error.log --open-files-limit=8192 --pid-file=/data/mysql/HE3.pid --socket=/tmp/mysql.sock --port=3306
            root     27235 25656  0 20:31 pts/2    00:00:00 grep mysql

            這里雖然啟動(dòng)成功了,但error日志里能捕捉到很多錯(cuò)誤信息,因?yàn)闆]有升級(jí)字典,諸如:

            2016-10-20T03:30:27.375466Z 0 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_program' has the wrong structure
            2016-10-20T03:30:27.375506Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_current' has the wrong structure
            2016-10-20T03:30:27.375536Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_history' has the wrong structure
            2016-10-20T03:30:27.375568Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_history_long' has the wrong structure
            2016-10-20T03:30:27.375598Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_thread_by_event_name' has the wrong structure

            Part2:系統(tǒng)表升級(jí)

            1.升級(jí)數(shù)據(jù)字典

            [root@HE3 ~]# /usr/local/mysql/bin/mysql_upgrade -uroot -pMANAGER
            mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.
            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.
            helei.helei                                        OK
            sys.sys_config                                     OK
            Upgrade process completed successfully.
            Checking if update is needed.

            2.重啟實(shí)例再次檢查error日志

            [root@HE3 ~]# /etc/init.d/mysqld restart

            Shutting down MySQL.. SUCCESS! 

            Starting MySQL. SUCCESS! 

            3.請(qǐng)保證一些路徑的設(shè)置和以前的my.cnf一致,如果設(shè)置錯(cuò)誤,很可能導(dǎo)致啟動(dòng)不了數(shù)據(jù)庫

            [ERROR] Could not use /data/slowlog/slow.log for logging

            我這里是由于慢日志的位置和老的mysql5.6路徑不一致,創(chuàng)建/data/slowlog即可,這里要仔細(xì)看報(bào)錯(cuò),然后根據(jù)報(bào)錯(cuò)來發(fā)現(xiàn)和解決問題。

            驗(yàn)證結(jié)果

            Part1:輸入用戶名密碼檢查結(jié)果

            [root@HE3 ~]# mysql -uroot -p
            Enter password: 
            Welcome to the MySQL monitor.  Commands end with ; or \g.
            Your MySQL connection id is 2
            Server version: 5.7.15-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> select version();
            +------------+
            | version()  |
            +------------+
            | 5.7.15-log |
            +------------+
            1 row in set (0.00 sec)

            Part2:驗(yàn)證庫和表是否有丟失

            mysql> show databases;
            +--------------------+
            | Database           |
            +--------------------+
            | information_schema |
            | helei              |
            | mysql              |
            | performance_schema |
            | sys                |
            | test               |
            +--------------------+
            6 rows in set (0.00 sec)

            升級(jí)5.7后,我們會(huì)發(fā)現(xiàn)多了一個(gè)sys庫,這個(gè)庫有很多的功能,以后再給大家慢慢介紹~

            ——總結(jié)——

            MySQL升級(jí)有多種方式,但無論采用何種方式,都要做好備份和回滾的準(zhǔn)備,以避免升級(jí)失敗所帶來的損失。由于筆者的水平有限,編寫時(shí)間也很倉促,文中難免會(huì)出現(xiàn)一些錯(cuò)誤或者不準(zhǔn)確的地方,不妥之處懇請(qǐng)讀者批評(píng)指正。

            當(dāng)前文章:MySQL5.6.25升級(jí)MySQL5.7.15
            分享鏈接:http://www.jbt999.com/article32/ppjepc.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、微信小程序App設(shè)計(jì)、用戶體驗(yàn)定制網(wǎng)站、營銷型網(wǎng)站建設(shè)

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

            h5響應(yīng)式網(wǎng)站建設(shè)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 轻轻操免费视频 | 国产一级a毛一级a做免费高清视频 | 自拍成人视频 | 亚洲小说区图片区都市 | 欧美日韩三区 |