windows下mysql5.6.12升級到5.6.47

windows下原數據庫爲mysql 5.6.12,現在需要升級到5.6的最終版本5.6.47

下載地址爲:

https://dev.mysql.com/downloads/mysql/

選擇合適的版本.

1.查看原mysql版本和數據目錄

 

C:\Users\Administrator>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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.12    |
+-----------+
1 row in set (0.00 sec)

查看mysql安裝目錄和數據文件目錄:


mysql> show variables like 'datadir';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| datadir       | e:\mysql\data\ |
+---------------+----------------+
1 row in set (0.00 sec)

mysql> show variables like 'basedir';
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| basedir       | e:\mysql |
+---------------+----------+
1 row in set (0.00 sec)

2.數據庫備份

在做之前需要對數據庫進行備份,可以使用冷備份或者mysqldump導出.

冷備份:

a)停止mysql數據庫

b)拷貝數據目錄

導出備份:

例如下面備份suq這個數據庫

E:\>mysqldump -uroot -p --default-character-set=utf8 --databases suq >suq.sql
Enter password: ****

 

3.安裝新的數據庫版本

3.1 停止mysql

E:\>net stop mysql
MySQL 服務正在停止.
MySQL 服務已成功停止。

 

3.2 刪除原來mysql服務

E:\>mysqld -remove mysql
Service successfully removed.

3.3 將原來的mysql目錄改名

原來的目錄爲e:\mysql,修改爲e:\mysql-5.6.12

 

3.4 將新版本的mysql安裝到原目錄中

a)解壓縮5.6.47的mysql到e:\mysql中

b)如果存在則刪除新解壓縮目錄中的data和my.ini

c)將改名後的目錄中的data和my.ini拷貝到e:\mysql中

這裏如果data目錄沒有存放到basedir下,則不需要拷貝data目錄.即要保證my.ini中指定的datadir是原來的數據文件目錄

這樣操作的好處就是不需要修改PATH環境變量再添加新的安裝路徑

 

3.5創建新的mysql服務

E:\>mysqld -install mysql
Service successfully installed

 

現在創建了新的mysql服務,服務名爲mysql,而且使用的是新版本的mysqld程序創建的.

 

3.6 啓動mysql,升級數據字典

 

E:\>net start mysql
mysql 服務正在啓動 .
mysql 服務已經啓動成功。

這個時候mysql已經版本已經是5.6.47了:

E:\>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.47 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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.47    |
+-----------+

 

但是還需要升級一下字典:

使用mysql_upgrade 進行升級,如果數據量很大可能會較慢:


E:\>mysql_upgrade -uroot -p
Enter password: ****
Looking for 'mysql.exe' as: e:\mysql\bin\mysql.exe
Looking for 'mysqlcheck.exe' as: e:\mysql\bin\mysqlcheck.exe
Running 'mysqlcheck with default connection arguments
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck with default connection arguments
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  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.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
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck with default connection arguments
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck with default connection arguments
Warning: Using a password on the command line interface can be insecure.
suq.t1                                             OK
OK

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章