翼度科技»论坛 编程开发 mysql 查看内容

mysql从5.7平滑升级到8.0.27的实现

7

主题

7

帖子

21

积分

新手上路

Rank: 1

积分
21
mysql升级过程

官网下载最新的mysql安装包

上传到服务器的/opt/mysql目录下解压:
  1. # 文件上传位置在/opt/mysql/下面
  2. cd /opt/mysql/

  3. # 解压安装包
  4. [root@zkmet mysql]# xz -d mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
  5. [root@zkmet mysql]# tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar

  6. # 文件夹重命名为mysql8
  7. mv mysql-8.0.27-linux-glibc2.12-x86_64 mysql8

  8. # 安装包移动(复制)至原安装包目录下,我的是/var/lib/
  9. cp mysql8 /var/lib/

  10. # 更改文件夹所属
  11. chown -R mysql.mysql /var/lib/mysql8/
复制代码
更改/etc/my.conf配置,末尾添加关键配置
  1. #for8.0
  2. sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
  3. character-set-server = utf8
  4. collation_server = utf8_general_ci
  5. basedir = /var/lib/mysql8
  6. skip_ssl
  7. default_authentication_plugin=mysql_native_password
复制代码
备份数据库、备份数据库、备份数据库。重要的话说三遍
万事俱备后,按照如下指示进行正式升级。
  1. # 进入原5.7 mysql命令行 正确关闭数据库
  2. [root@zkmet mysql]# mysql -uroot -p
  3. Enter password:

  4. mysql> select version();
  5. +------------+
  6. | version()  |
  7. +------------+
  8. | 5.7.23-log |
  9. +------------+
  10. 1 row in set (0.00 sec)

  11. mysql> show variables like 'innodb_fast_shutdown';
  12. +----------------------+-------+
  13. | Variable_name        | Value |
  14. +----------------------+-------+
  15. | innodb_fast_shutdown | 1     |
  16. +----------------------+-------+
  17. 1 row in set (0.00 sec)
  18. # 确保数据都刷到硬盘上,更改成0
  19. mysql> set global innodb_fast_shutdown=0;
  20. Query OK, 0 rows affected (0.00 sec)

  21. mysql> shutdown;
  22. Query OK, 0 rows affected (0.00 sec)

  23. mysql> exit
  24. Bye
复制代码
退出至终端 用mysql8.0.19客户端直接启动
  1. # 执行命令/var/lib/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
  2. [root@zkmet mysql]# /var/lib/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &

  3. # 我的一直卡在这个页面,还以为出错了,可以另起一个客户端,登录到数据库select version();查看数据库版本是否更新成功。
  4. [1] 1787
  5. [root@zkmet mysql]# 2021-11-12T06:32:56.314320Z mysqld_safe Logging to '/var/log/mysqld.log'.
  6. 2021-11-12T06:32:56.337533Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  7. 2021-11-12T07:26:29.183302Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
复制代码
卡在上一步可另起客户端登录mysql
  1. [root@zkmet etc]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 14
  5. Server version: 8.0.27 MySQL Community Server - GPL

  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.

  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  11. mysql> select version();
  12. +-----------+
  13. | version() |
  14. +-----------+
  15. | 8.0.27    |
  16. +-----------+
  17. 1 row in set (0.01 sec)
复制代码
到这里其实证明数据库平滑升级成功了。**但是:**再修改一点配置
  1. # 修改PATH变量
  2. [root@zkmet etc]# vi /etc/profile
  3. # 将PATH中的/usr/local/mysql/bin改为/usr/local/mysql8/bin

  4. # 生效验证
  5. [root@zkmet etc]# source /etc/profile
  6. [root@zkmet etc]# which mysql
  7. /var/lib/mysql8/bin/mysql
  8. [root@zkmet etc]# mysql -V
  9. [root@zkmet etc]# mysql -V
  10. mysql  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
复制代码
问题一:

连接数据库报错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
  1. [root@zkmet ~]# mysql -uroot -p
  2. Enter password:
  3. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
复制代码
解决方式,找到 mysql.sock
  1. [root@zkmet etc]# find / -name mysql.sock
  2. /var/lib/mysql/mysql.sock
复制代码
修改my.conf配置
  1. [mysqld]
  2. socket = /var/lib/mysql/mysql.sock

  3. [client]
  4. socket = /var/lib/mysql/mysql.sock
复制代码
问题二:

改完my.conf配置后直接重启mysqld发现重启不了
  1. [root@zkmet bin]# service mysqld restart
  2. 停止 mysqld:                                              [确定]
  3. MySQL Daemon failed to start.
  4. 正在启动 mysqld:                                          [失败]
复制代码
查看/var/log/mysqld.log日志
  1. 07:47:22 UTC - mysqld got signal 6 ;
  2. This could be because you hit a bug. It is also possible that this binary
  3. or one of the libraries it was linked against is corrupt, improperly built,
  4. or misconfigured. This error can also be caused by malfunctioning hardware.
  5. Attempting to collect some information that could help diagnose the problem.
  6. As this is a crash and something is definitely wrong, the information
  7. collection process might fail.

  8. key_buffer_size=8388608
  9. read_buffer_size=131072
  10. max_used_connections=0
  11. max_threads=151
  12. thread_count=0
  13. connection_count=0
  14. It is possible that mysqld could use up to
  15. key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 K  bytes of memory
  16. Hope that's ok; if not, decrease some variables in the equation.

  17. Thread pointer: 0x0
  18. Attempting backtrace. You can use the following information to find out
  19. where mysqld died. If you see no messages after this, something went
  20. terribly wrong...
  21. stack_bottom = 0 thread_stack 0x40000
  22. /usr/sbin/mysqld(my_print_stacktrace+0x35)[0xf559e5]
  23. /usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x7d4bd4]
  24. /lib64/libpthread.so.0[0x3a2fe0f710]
  25. /lib64/libc.so.6(gsignal+0x35)[0x3a2fa32925]
  26. /lib64/libc.so.6(abort+0x175)[0x3a2fa34105]
  27. /usr/sbin/mysqld(_Z18ut_print_timestampP8_IO_FILE+0x0)[0x7c3cf8]
  28. /usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0xb3)[0x11610d3]
  29. /usr/sbin/mysqld[0x1203338]
  30. /usr/sbin/mysqld[0x1203b98]
  31. /usr/sbin/mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x29e)[0x120c12e]
  32. /usr/sbin/mysqld[0x11bf616]
  33. /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x40)[0x11c0090]
  34. /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0xd21)[0x11a1f01]
  35. /usr/sbin/mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x15d)[0x114244d]
  36. /usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2981)[0x11185c1]
  37. /usr/sbin/mysqld[0x1000e8a]
  38. /usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x8219f1]
  39. /usr/sbin/mysqld[0xd39d26]
  40. /usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x3e4)[0xd3af44]
  41. /usr/sbin/mysqld[0x7cb006]
  42. /usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x957)[0x7ce657]
  43. /lib64/libc.so.6(__libc_start_main+0xfd)[0x3a2fa1ed1d]
  44. /usr/sbin/mysqld[0x7c4ac9]
  45. The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
  46. information that should help you find out what is causing the crash.
  47. 2021-11-12T07:56:58.641391Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  48. 2021-11-12T07:56:58.641442Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
  49. 2021-11-12T07:56:58.644936Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.25-log) starting as process 6345 ...
  50. 2021-11-12T07:56:58.644998Z 0 [ERROR] Can't find error-message file '/usr/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
  51. 2021-11-12T07:56:58.651266Z 0 [Note] InnoDB: PUNCH HOLE support available
  52. 2021-11-12T07:56:58.651337Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  53. 2021-11-12T07:56:58.651344Z 0 [Note] InnoDB: Uses event mutexes
  54. 2021-11-12T07:56:58.651353Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
  55. 2021-11-12T07:56:58.651361Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  56. 2021-11-12T07:56:58.651370Z 0 [Note] InnoDB: Using Linux native AIO
  57. 2021-11-12T07:56:58.651667Z 0 [Note] InnoDB: Number of pools: 1
  58. 2021-11-12T07:56:58.651794Z 0 [Note] InnoDB: Using CPU crc32 instructions
  59. 2021-11-12T07:56:58.654249Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  60. 2021-11-12T07:56:58.667767Z 0 [Note] InnoDB: Completed initialization of buffer pool
  61. 2021-11-12T07:56:58.671260Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  62. 2021-11-12T07:56:58.684155Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
  63. 2021-11-12 15:56:58 0x7f73adfaf720  InnoDB: Assertion failure in thread 140134816872224 in file ut0ut.cc line 942
  64. InnoDB: We intentionally generate a memory trap.
  65. InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
  66. InnoDB: If you get repeated assertion failures or crashes, even
  67. InnoDB: immediately after the mysqld startup, there may be
  68. InnoDB: corruption in the InnoDB tablespace. Please refer to
  69. InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
  70. InnoDB: about forcing recovery.
  71. 07:56:58 UTC - mysqld got signal 6 ;
  72. This could be because you hit a bug. It is also possible that this binary
  73. or one of the libraries it was linked against is corrupt, improperly built,
  74. or misconfigured. This error can also be caused by malfunctioning hardware.
  75. Attempting to collect some information that could help diagnose the problem.
  76. As this is a crash and something is definitely wrong, the information
  77. collection process might fail.

  78. key_buffer_size=8388608
  79. read_buffer_size=131072
  80. max_used_connections=0
  81. max_threads=151
  82. thread_count=0
  83. connection_count=0
  84. It is possible that mysqld could use up to
  85. key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 K  bytes of memory
  86. Hope that's ok; if not, decrease some variables in the equation.

  87. Thread pointer: 0x0
  88. Attempting backtrace. You can use the following information to find out
  89. where mysqld died. If you see no messages after this, something went
  90. terribly wrong...
  91. stack_bottom = 0 thread_stack 0x40000
  92. /usr/sbin/mysqld(my_print_stacktrace+0x35)[0xf559e5]
  93. /usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x7d4bd4]
  94. /lib64/libpthread.so.0[0x3a2fe0f710]
  95. /lib64/libc.so.6(gsignal+0x35)[0x3a2fa32925]
  96. /lib64/libc.so.6(abort+0x175)[0x3a2fa34105]
  97. /usr/sbin/mysqld(_Z18ut_print_timestampP8_IO_FILE+0x0)[0x7c3cf8]
  98. /usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0xb3)[0x11610d3]
  99. /usr/sbin/mysqld[0x1203338]
  100. /usr/sbin/mysqld[0x1203b98]
  101. /usr/sbin/mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x29e)[0x120c12e]
  102. /usr/sbin/mysqld[0x11bf616]
  103. /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x40)[0x11c0090]
  104. /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0xd21)[0x11a1f01]
  105. /usr/sbin/mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x15d)[0x114244d]
  106. /usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2981)[0x11185c1]
  107. /usr/sbin/mysqld[0x1000e8a]
  108. /usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x8219f1]
  109. /usr/sbin/mysqld[0xd39d26]
  110. /usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x3e4)[0xd3af44]
  111. /usr/sbin/mysqld[0x7cb006]
  112. /usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x957)[0x7ce657]
  113. /lib64/libc.so.6(__libc_start_main+0xfd)[0x3a2fa1ed1d]
  114. /usr/sbin/mysqld[0x7c4ac9]
  115. The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
  116. information that should help you find out what is causing the crash.
复制代码
这里我其实是比较蒙的,以为数据库玩崩了。所以一定要记得备份数据库。
  1. # 都准备重装mysql的,后来死马当活马医,尝试执行下面的命令又好了
  2. /var/lib/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
复制代码
参考链接

MySQL5.7升级到8.0过程详解
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket 解决办法
到此这篇关于mysql从5.7平滑升级到8.0.27的实现的文章就介绍到这了,更多相关mysql5.7平滑升级到8.0.27内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

来源:https://www.jb51.net/database/322186rbg.htm
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具