点子鸽 发表于 2024-6-11 01:44:21

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

mysql升级过程

官网下载最新的mysql安装包

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

# 解压安装包
# xz -d mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
# tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar

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

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

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

mysql> select version();
+------------+
| version()|
+------------+
| 5.7.23-log |
+------------+
1 row in set (0.00 sec)

mysql> show variables like 'innodb_fast_shutdown';
+----------------------+-------+
| Variable_name      | Value |
+----------------------+-------+
| innodb_fast_shutdown | 1   |
+----------------------+-------+
1 row in set (0.00 sec)
# 确保数据都刷到硬盘上,更改成0
mysql> set global innodb_fast_shutdown=0;
Query OK, 0 rows affected (0.00 sec)

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

mysql> exit
Bye退出至终端 用mysql8.0.19客户端直接启动
# 执行命令/var/lib/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
# /var/lib/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &

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

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

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() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.01 sec)到这里其实证明数据库平滑升级成功了。**但是:**再修改一点配置
# 修改PATH变量
# vi /etc/profile
# 将PATH中的/usr/local/mysql/bin改为/usr/local/mysql8/bin

# 生效验证
# source /etc/profile
# which mysql
/var/lib/mysql8/bin/mysql
# mysql -V
# mysql -V
mysqlVer 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)
# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)解决方式,找到 mysql.sock
# find / -name mysql.sock
/var/lib/mysql/mysql.sock修改my.conf配置

socket = /var/lib/mysql/mysql.sock


socket = /var/lib/mysql/mysql.sock
问题二:

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

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 Kbytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)
/lib64/libpthread.so.0
/lib64/libc.so.6(gsignal+0x35)
/lib64/libc.so.6(abort+0x175)
/usr/sbin/mysqld(_Z18ut_print_timestampP8_IO_FILE+0x0)
/usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0xb3)
/usr/sbin/mysqld
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x29e)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x40)
/usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0xd21)
/usr/sbin/mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x15d)
/usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2981)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x3e4)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x957)
/lib64/libc.so.6(__libc_start_main+0xfd)
/usr/sbin/mysqld
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2021-11-12T07:56:58.641391Z 0 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-12T07:56:58.641442Z 0 'NO_AUTO_CREATE_USER' sql mode was not set.
2021-11-12T07:56:58.644936Z 0 /usr/sbin/mysqld (mysqld 5.7.25-log) starting as process 6345 ...
2021-11-12T07:56:58.644998Z 0 Can't find error-message file '/usr/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2021-11-12T07:56:58.651266Z 0 InnoDB: PUNCH HOLE support available
2021-11-12T07:56:58.651337Z 0 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-11-12T07:56:58.651344Z 0 InnoDB: Uses event mutexes
2021-11-12T07:56:58.651353Z 0 InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2021-11-12T07:56:58.651361Z 0 InnoDB: Compressed tables use zlib 1.2.11
2021-11-12T07:56:58.651370Z 0 InnoDB: Using Linux native AIO
2021-11-12T07:56:58.651667Z 0 InnoDB: Number of pools: 1
2021-11-12T07:56:58.651794Z 0 InnoDB: Using CPU crc32 instructions
2021-11-12T07:56:58.654249Z 0 InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-11-12T07:56:58.667767Z 0 InnoDB: Completed initialization of buffer pool
2021-11-12T07:56:58.671260Z 0 InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-11-12T07:56:58.684155Z 0 InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
2021-11-12 15:56:58 0x7f73adfaf720InnoDB: Assertion failure in thread 140134816872224 in file ut0ut.cc line 942
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
07:56:58 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 Kbytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)
/lib64/libpthread.so.0
/lib64/libc.so.6(gsignal+0x35)
/lib64/libc.so.6(abort+0x175)
/usr/sbin/mysqld(_Z18ut_print_timestampP8_IO_FILE+0x0)
/usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0xb3)
/usr/sbin/mysqld
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x29e)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x40)
/usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0xd21)
/usr/sbin/mysqld(_Z31trx_rseg_get_n_undo_tablespacesPm+0x15d)
/usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x2981)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x3e4)
/usr/sbin/mysqld
/usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x957)
/lib64/libc.so.6(__libc_start_main+0xfd)
/usr/sbin/mysqld
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.这里我其实是比较蒙的,以为数据库玩崩了。所以一定要记得备份数据库。
# 都准备重装mysql的,后来死马当活马医,尝试执行下面的命令又好了
/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】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: mysql从5.7平滑升级到8.0.27的实现