iis服务器助手广告
返回顶部
首页 > 资讯 > 数据库 >redhat 6.5 mysql 升级5.5.48经mysql 5.6.32至mysql 5.7.16实施概略
  • 879
分享到

redhat 6.5 mysql 升级5.5.48经mysql 5.6.32至mysql 5.7.16实施概略

2024-04-02 19:04:59 879人浏览 泡泡鱼
摘要

1,os version redhat 6.5 2,旧版本Mysql 5.5.48创建测试数据库及测试表 mysql> create database zxy; Query OK, 1 row a

1,os version
redhat 6.5


2,旧版本Mysql 5.5.48创建测试数据库及测试表
mysql> create database zxy;
Query OK, 1 row affected (0.00 sec)


mysql> use zxy;
Database changed
mysql> create table t_zxy(a int);
Query OK, 0 rows affected (0.03 sec)


mysql> insert into t_zxy values(1);
Query OK, 1 row affected (0.01 sec)


mysql> commit;
Query OK, 0 rows affected (0.00 sec)


3,查询旧版本MYSQL 5.5.48 DATA DIR及相关Socket文件及PID
mysql> show variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.00 sec)


mysql> show variables like 'socket';
+---------------+---------------------------+
| Variable_name | Value                     |
+---------------+---------------------------+
| socket        | /var/lib/mysql/mysql.sock |
+---------------+---------------------------+
1 row in set (0.00 sec)


mysql> show variables like '%pid%';
+---------------+---------------------------------+
| Variable_name | Value                           |
+---------------+---------------------------------+
| pid_file      | /var/lib/mysql/mysqlupgrade.pid |
+---------------+---------------------------------+
1 row in set (0.01 sec)


4,旧版本MYSQL 5.5.48没有使用配置文件my.cnf


[root@mysqlupgrade mysql_5548_dir]# ps -ef|grep -i mysql
root      6563  5378  0 16:52 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --user=root
root      6643  6563  0 16:52 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root 
--log-error=/var/lib/mysql/mysqlupgrade.err --pid-file=/var/lib/mysql/mysqlupgrade.pid
root      6712  5378  0 17:02 pts/0    00:00:00 grep -i mysql




[root@mysqlupgrade mysql_5548_dir]# ps aux|grep mysql|grep -i my.cnf
[root@mysqlupgrade mysql_5548_dir]# 




5,旧版本mysql 5.5.48执行innodb_fast_shutdown=0
[root@mysqlupgrade mysql_5548_dir]# mysql -u root -p --execute='set global innodb_fast_shutdown=0'
Enter passWord
[root@mysqlupgrade mysql_5548_dir]# 




6,shutdown 旧版本mysql 5.5.48
[root@mysqlupgrade mysql_5548_dir]# mysqladmin -u root -p shutdown
Enter password: 
180503 17:04:54 mysqld_safe mysqld from pid file /var/lib/mysql/mysqlupgrade.pid ended
[1]+  Done                    mysqld_safe --user=root
[root@mysqlupgrade mysql_5548_dir]# ps -ef|grep mysql
root      6734  5378  0 17:04 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql_5548_dir]# 


7,移除旧版本mysql 5.5.48
[root@mysqlupgrade mysql_5548_dir]# rpm -qa|grep -i mysql
MySQL-devel-5.5.48-1.el6.x86_64
MySQL-server-5.5.48-1.el6.x86_64
MySQL-client-5.5.48-1.el6.x86_64
[root@mysqlupgrade mysql_5548_dir]# 




[root@mysqlupgrade mysql_5548_dir]# yum -y remove MySQL-client-5.5.48-1.el6.x86_64


[root@mysqlupgrade mysql_5548_dir]# yum -y remove MySQL-server-5.5.48-1.el6.x86_64




[root@mysqlupgrade mysql_5548_dir]# yum -y remove MySQL-devel-5.5.48-1.el6.x86_64




[root@mysqlupgrade mysql_5548_dir]# rpm -qa|grep -i mysql
[root@mysqlupgrade mysql_5548_dir]# 


8,确认旧版本MYSQL 5.5.48 DATA DIR及相关存在
[root@mysqlupgrade mysql_5548_dir]# ll /var/lib/mysql
total 28700
-rw-rw----. 1 root  root  18874368 May  3 17:04 ibdata1
-rw-rw----. 1 root  root   5242880 May  3 17:04 ib_logfile0
-rw-rw----. 1 root  root   5242880 May  3 16:52 ib_logfile1
drwx--x--x. 2 mysql mysql     4096 May  3 16:50 mysql
-rw-r-----. 1 root  root      2362 May  3 17:04 mysqlupgrade.err
drwx------. 2 mysql mysql     4096 May  3 16:50 perfORMance_schema
-rw-r--r--. 1 root  root       111 May  3 16:50 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql      111 May  3 16:50 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql     4096 May  3 16:50 test
drwx------. 2 root  root      4096 May  3 16:57 zxy


9,安装中间版本mysql 5.6.32



[root@mysqlupgrade mysql5632_dir]# rpm -qa|grep -i mysql
MySQL-server-5.6.32-1.el6.x86_64
MySQL-client-5.6.32-1.el6.x86_64
[root@mysqlupgrade mysql5632_dir]# 


10,以旧版本的数据文件目录 启动中间版本mysql 5.6.32
[root@mysqlupgrade mysql5632_dir]# mysqld_safe --user=root --datadir=/var/lib/mysql &
[1] 6830
[root@mysqlupgrade mysql5632_dir]# 180503 17:13:34 mysqld_safe Logging to '/var/lib/mysql/mysqlupgrade.err'.
180503 17:13:34 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


[root@mysqlupgrade mysql5632_dir]# 




[root@mysqlupgrade mysql5632_dir]# ps -ef|grep mysql
root      6830  5378  0 17:13 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --user=root --datadir=/var/lib/mysql
root      6918  6830  0 17:13 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root --log-error=/var/lib/mysql/mysqlupgrade.err --pid-file=/var/lib/mysql/mysqlupgrade.pid
root      6942  5378  0 17:14 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql5632_dir]# 


11,升级中间版本mysql 5.6.32数据字典及相关元数据
[root@mysqlupgrade mysql5632_dir]# mysql_upgrade  -u root -p
Enter password: 
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
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.host                                         OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.servers                                      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.
zxy.t_zxy                                          OK
OK
[root@mysqlupgrade mysql5632_dir]# 




12,shutdown 中间版本mysql 5.6.32
[root@mysqlupgrade mysql5632_dir]# mysqladmin  -u root -p shutdown
Enter password: 
180503 17:15:58 mysqld_safe mysqld from pid file /var/lib/mysql/mysqlupgrade.pid ended
[1]+  Done                    mysqld_safe --user=root --datadir=/var/lib/mysql
[root@mysqlupgrade mysql5632_dir]# 
[root@mysqlupgrade mysql5632_dir]# ps -ef|grep mysql
root      6971  5378  0 17:16 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql5632_dir]# ps -ef|grep -i mysql
root      6973  5378  0 17:16 pts/0    00:00:00 grep -i mysql


13,重启中间版本mysql 5.6.32
[root@mysqlupgrade mysql5632_dir]# mysqld_safe --user=root --datadir=/var/lib/mysql &
[1] 6976
[root@mysqlupgrade mysql5632_dir]# 180503 17:17:05 mysqld_safe Logging to '/var/lib/mysql/mysqlupgrade.err'.
180503 17:17:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


[root@mysqlupgrade mysql5632_dir]# ps -ef|grep mysql
root      6976  5378  0 17:17 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --user=root --datadir=/var/lib/mysql
root      7064  6976  7 17:17 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root --log-error=/var/lib/mysql/mysqlupgrade.err --pid-file=/var/lib/mysql/mysqlupgrade.pid
root      7087  5378  0 17:17 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql5632_dir]# 




14,验证中间版本mysql 5.6.32运行是否正常及相关数据是否升级完整
[root@mysqlupgrade mysql5632_dir]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.32 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| zxy                |
+--------------------+
5 rows in set (0.00 sec)


mysql> use zxy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> select * from t_zxy;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)


mysql> 




15,可见安装中间版本mysql 5.6.32没有产生配置文件 my.cnf
[root@mysqlupgrade mysql5632_dir]# updatedb
[root@mysqlupgrade mysql5632_dir]# locate my.cnf
/etc/my.cnf.d
[root@mysqlupgrade mysql5632_dir]# 


16,中间版本mysql 5.6.32 innodb_fast_shutdown
[root@mysqlupgrade mysql5632_dir]# !40
mysql -u root -p --execute='set global innodb_fast_shutdown=0'
Enter password: 
[root@mysqlupgrade mysql5632_dir]# 


17,shutdown中间版本mysql 5.6.32
[root@mysqlupgrade mysql5632_dir]# !41
mysqladmin -u root -p shutdown
Enter password: 
180503 17:20:31 mysqld_safe mysqld from pid file /var/lib/mysql/mysqlupgrade.pid ended
[1]+  Done                    mysqld_safe --user=root --datadir=/var/lib/mysql
[root@mysqlupgrade mysql5632_dir]# 
[root@mysqlupgrade mysql5632_dir]# ps -ef|grep mysql
root      7108  5378  0 17:20 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql5632_dir]# ps -ef|grep -i mysql
root      7110  5378  0 17:20 pts/0    00:00:00 grep -i mysql
[root@mysqlupgrade mysql5632_dir]# 




18,移除中间版本mysql 5.6.32
[root@mysqlupgrade mysql5632_dir]# rpm -qa|grep -i mysql
MySQL-server-5.6.32-1.el6.x86_64
MySQL-client-5.6.32-1.el6.x86_64
[root@mysqlupgrade mysql5632_dir]# 




yum -y remove MySQL-server-5.6.32-1.el6.x86_64
yum -y remove MySQL-client-5.6.32-1.el6.x86_64




[root@mysqlupgrade mysql5632_dir]# rpm -qa|grep -i mysql
[root@mysqlupgrade mysql5632_dir]# 




19,安装新版本mysql 5.7.16



[root@mysqlupgrade mysql_new_version_dir]# rpm -qa|grep mysql
mysql-community-client-5.7.16-1.el6.x86_64
mysql-community-libs-5.7.16-1.el6.x86_64
mysql-community-server-5.7.16-1.el6.x86_64
mysql-community-common-5.7.16-1.el6.x86_64
[root@mysqlupgrade mysql_new_version_dir]# 




20,以旧版本的数据文件目录 启动新版本mysql 5.7.16
[root@mysqlupgrade mysql_new_version_dir]# mysqld_safe --user=root --datadir=/var/lib/mysql &
[1] 7153
[root@mysqlupgrade mysql_new_version_dir]# 2018-05-03T09:24:58.397790Z mysqld_safe Logging to '/var/log/mysqld.log'.
2018-05-03T09:24:58.423138Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


[root@mysqlupgrade mysql_new_version_dir]# ps -ef|grep mysql
root      7153  5378  0 17:24 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --user=root --datadir=/var/lib/mysql
root      7311  7153  5 17:24 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      7340  5378  0 17:25 pts/0    00:00:00 grep mysql




21,升级新版本mysql 5.7.16数据字典及相关元数据
[root@mysqlupgrade mysql_new_version_dir]# mysql_upgrade -u root -p
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.host                                         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
zxy.t_zxy                                          OK
Upgrade process completed successfully.
Checking if update is needed.
[root@mysqlupgrade mysql_new_versio




22,关闭新版本mysql 5.7.16
[root@mysqlupgrade mysql_new_version_dir]# mysqladmin  -u root -p shutdown
Enter password: 
[root@mysqlupgrade mysql_new_version_dir]# 2018-05-03T09:26:28.321222Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended


[1]+  Done                    mysqld_safe --user=root --datadir=/var/lib/mysql
[root@mysqlupgrade mysql_new_version_dir]# ps -ef|grep -i mysql
root      7353  5378  0 17:26 pts/0    00:00:00 grep -i mysql
[root@mysqlupgrade mysql_new_version_dir]# 




23,重启新版本mysql 5.7.16
[root@mysqlupgrade mysql_new_version_dir]#  mysqld_safe --user=root --datadir=/var/lib/mysql &
[1] 7356
[root@mysqlupgrade mysql_new_version_dir]# 2018-05-03T09:26:51.813308Z mysqld_safe Logging to '/var/log/mysqld.log'.
2018-05-03T09:26:51.835876Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql


[root@mysqlupgrade mysql_new_version_dir]# ps -ef|grep mysql
root      7356  5378  0 17:26 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --user=root --datadir=/var/lib/mysql
root      7514  7356  3 17:26 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=root --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      7543  5378  0 17:26 pts/0    00:00:00 grep mysql
[root@mysqlupgrade mysql_new_version_dir]# 




24,验证新版本mysql 5.7.16运行是否正常及相关数据是否升级完整
[root@mysqlupgrade mysql_new_version_dir]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.16 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
| zxy                |
+--------------------+
6 rows in set (0.00 sec)


mysql> use zxy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> select * from t_zxy;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)


mysql> 

您可能感兴趣的文档:

--结束END--

本文标题: redhat 6.5 mysql 升级5.5.48经mysql 5.6.32至mysql 5.7.16实施概略

本文链接: https://www.lsjlt.com/news/46820.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • sql如何写循环语句
    sql 中没有传统的循环语句,但可使用递归 cte 模拟循环:创建递归 cte,包含"iteration"列来跟踪循环次数。递归查询更新"iteration"列并满足循环条件。使用 se...
    99+
    2024-06-08
  • sql如何过滤重复
    sql 中过滤重复记录的方法包括:使用 distinct 关键字去除重复值。使用 group by 子句分组结果并返回每组的第一行。使用 count() 函数查找出现多次的值并进一步过滤...
    99+
    2024-06-08
  • sql中如何实现列转行
    sql中实现列转行的操作有两种方式:使用 union 操作符通过垂直合并查询结果实现列转行。使用 pivot 函数将列数据转换为行数据,其中 pivot 函数的语法为:pivo...
    99+
    2024-06-08
    聚合函数
  • sql函数如何向上取整
    sql 中 ceiling() 函数向上取整,将数值舍入到最近的整数,语法为 ceiling(numeric_expression)。示例:向上取整 2.5 为 3,-10.2 为 -1...
    99+
    2024-06-08
  • sql如何查询字段重复数据
    可以使用 sql 的 group by 和 count() 函数、distinct 和 count() 函数或窗口函数 row_number() 来查询重复字段数据。 SQL 查询重复...
    99+
    2024-06-08
  • sql如何创建视图
    视图是 sql 中的虚拟表,从基础表中派生数据。创建视图的步骤包括:使用 create view 语句指定视图名称和从基础表中选择的列。可选地指定基础表之间的连接和应用过滤器。视图简化了...
    99+
    2024-06-08
    敏感数据
  • sql如何计算百分比
    有三种主要方法可以利用 sql 计算百分比:直接计算、使用窗口函数以及使用 case 表达式。直接计算通过将分子除以分母并乘以 100 获得百分比;窗口函数允许根据组按分母值计算百分比;...
    99+
    2024-06-08
  • 如何用sql将时间戳转换日期格式
    要将 sql 中的时间戳转换成日期格式,可以使用 to_char() 函数:to_char(timestamp_column, 'yyyy-mm-dd') 将时间戳转...
    99+
    2024-06-08
  • sql如何在表中增加一列
    如何在 sql 表中增加一列?使用 alter table 语句,指定表名、列名和数据类型;可选设置 not null 约束和默认值;运行 alter table 语句将新列添加到表中。...
    99+
    2024-06-08
  • sql如何断开数据库的使用
    可以使用 sql 语句断开数据库连接,包括:1. close 语句:立即关闭指定连接;2. disconnect 语句:关闭连接并释放资源;3. end transaction 语句:提...
    99+
    2024-06-08
    python
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作