0


mysql实战——mysql5.7升级到mysql8.0

1、上传mysql8.0压缩包到/usr/local目录下

tar -zxvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz

mv mysql-8.0.25-linux-glibc2.12-x86_64 mysql8

#更改文件夹所属

chown -R mysql.mysql /usr/local/mysql8/

2、更改配置文件my.cnf

vi /etc/my.cnf

最后几个for8.0的参数要格外注意

[mysqld]
user = mysql
datadir = /data/mysql/data
port = 3306

socket = /data/mysql/tmp/mysql.sock
pid-file = /data/mysql/tmp/mysqld.pid
tmpdir = /data/mysql/tmp
skip_name_resolve = 1
max_connections = 2000
group_concat_max_len = 1024000
lower_case_table_names = 1
log_timestamps=SYSTEM
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096
default_time_zone = '+8:00'

#logs
server-id = 1003306
log-error = /data/mysql/logs/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log
long_query_time = 3
log-bin = /data/mysql/logs/binlog
binlog_format = row
log_bin_trust_function_creators = 1
gtid_mode = ON
enforce_gtid_consistency = ON

#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 = /usr/local/mysql8
skip_ssl
default_authentication_plugin=mysql_native_password

楼主只改了for8.0下的配置,别的和mysql5.7相同,还改动了datadir路径和basedir路径。

3、前期配置修改完了,下面执行升级程序

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.43 |
+-----------+
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.22 sec)

mysql> set global innodb_fast_shutdown=0;
Query OK, 0 rows affected (0.00 sec)

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

mysql> exit
[root@centos7 local]# /usr/local/mysql8/bin/mysqld_safe --defaults-file=/etc/my .cnf --user=mysql &
[1] 3643
[root@centos7 local]# 2024-05-20T09:31:10.199622Z mysqld_safe Logging to '/usr/ local/mysql/data/centos7.err'.
2024-05-20T09:31:10.348237Z mysqld_safe Starting mysqld daemon with databases f rom /usr/local/mysql/data

[root@centos7 bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.25 MySQL Community Server - GPL

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

4、修改环境变量

修改mysql服务启动项配置

vi /etc/init.d/mysql

修改basedir目录

basedir=/usr/local/mysql8

标签: mysql 数据库

本文转载自: https://blog.csdn.net/zyjzyjjyzjyz/article/details/139089179
版权归原作者 zyjzyjjyzjyz 所有, 如有侵权,请联系我们删除。

“mysql实战——mysql5.7升级到mysql8.0”的评论:

还没有评论