mysql数据库版本升级

mysql数据库5.7.31升级到5.7.33

首先看下最后升级后的目录情况

[root@mysql-6-58 ~]# tree -L 1 /dsj
/dsj
├── backup --备份的31的全库数据
├── binlog --33的binglog
├── binlog31 --31的binglog
├── data    --33的数据目录
├── data31  --31的数据目录 
├── dbbackup --mysql 定期备份文件
├── mysqldump 
├── script --运维脚本
└── tmp     --mysql tmpdir

1.备份数据文件

[root@mysql-6-58 dsj]# nohup cp -rp data31 data &

2.备份binlog日志文件

[root@mysql-6-58 dsj]# cp -rp binlog31 binlog

3.备份启动文件

[root@mysql-6-58 etc]# mv /usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/mysqld31.service

4.备份配置文件

mv /etc/my.cnf /etc/my31.cnf

5.查看原先的mysql rpm包,并卸载

[root@mysql-6-58 dsj]# rpm -qa |grep mysql
mysql-community-libs-5.7.31-1.el7.x86_64
mysql-community-client-5.7.31-1.el7.x86_64
mysql-community-server-5.7.31-1.el7.x86_64
mysql-community-common-5.7.31-1.el7.x86_64
rpm -e --nodeps mysql-community-server-5.7.31-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-5.7.31-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-compat-5.7.31-1.el7.x86_64
rpm -e --nodeps mysql-community-client-5.7.31-1.el7.x86_64
rpm -e --nodeps mysql-community-common-5.7.31-1.el7.x86_64

6.安装33版本的mysql,安装解压好的几个rpm包
(这里只列出两个)

[root@mysql-6-58 lc]# rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
[root@mysql-6-58 lc]# rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm

7.修改mysql配置文件
mysql配置文件:

# more /etc/my.cnf

----------------/etc/my.cnf begin--------------------
[mysqld]
#admin
datadir = /dsj/data
tmpdir = /dsj/tmp
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER
lower_case_table_names=1
character-set-server=utf8mb4
collation-server=utf8mb4_bin
skip_name_resolve=1
secure_file_priv=/var/lib/mysql-files
log-error=/var/log/mysqld.log
local_infile=0
slow_query_log=1
long_query_time=0.5
expire_logs_days = 20
event_scheduler=1

#replication
server_id=658
log_bin=/dsj/binlog/mysql-bin
relay_log=relay-bin
relay_log_recovery=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
gtid_mode=on
log_slave_updates=1
enforce_gtid_consistency=1
skip_slave_start=1
binlog_format=ROW
sync_master_info=1
slave_parallel_workers=4
binlog_checksum=CRC32
master_verify_checksum=1
slave_sql_verify_checksum=1
binlog_rows_query_log_events=1
slave_net_timeout=30

#performance
innodb_buffer_pool_size=16000M
read_buffer_size=4M
sort_buffer_size=4M
join_buffer_size=4M
innodb_log_file_size=512M
back_log=500
max_connections=2000
open_files_limit=100000
innodb_open_files=100000
table_open_cache=20000
table_definition_cache=20000
max_allowed_packet=40M

[client]
default-character-set=utf8
------------------/etc/my.cnf end---------------------------

8.给数据目录赋权

chown -R mysql:mysql /dsj/data
chown -R mysql:mysql /dsj/binlog

9.修改启动项

# vi /usr/lib/systemd/system/mysqld.service

LimitNOFILE默认5000,改为open_files_limit指定的值(100000)

10.启动mysql,密码为原密码

systemctl daemon-reload
systemctl start mysqld

11.更新数据字典

[root@mysql-6-58 dsj]# /usr/bin/mysql_upgrade -uroot -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.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
Upgrade process completed successfully.
Checking if update is needed.

12.重启mysql

[root@mysql-6-58 dsj]# systemctl restart mysqld

13.查看下error-log如果没有报错就是升级成功,有错改错

2021-06-08T08:01:03.164008Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-08T08:01:03.165158Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.33-log) starting as process 1238 ...
2021-06-08T08:01:03.168897Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-06-08T08:01:03.168944Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-06-08T08:01:03.168950Z 0 [Note] InnoDB: Uses event mutexes
2021-06-08T08:01:03.168955Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-06-08T08:01:03.168959Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-06-08T08:01:03.168965Z 0 [Note] InnoDB: Using Linux native AIO
2021-06-08T08:01:03.169997Z 0 [Note] InnoDB: Number of pools: 1
2021-06-08T08:01:03.170149Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-06-08T08:01:03.171707Z 0 [Note] InnoDB: Initializing buffer pool, total size = 16G, instances = 8, chunk size = 128M
2021-06-08T08:01:04.098302Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-06-08T08:01:04.200374Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-06-08T08:01:04.213399Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2021-06-08T08:01:04.498040Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-06-08T08:01:04.498169Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-06-08T08:01:04.551900Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-06-08T08:01:04.553018Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-06-08T08:01:04.553047Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-06-08T08:01:04.553904Z 0 [Note] InnoDB: Waiting for purge to start
2021-06-08T08:01:04.604114Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 2748025
2021-06-08T08:01:04.604685Z 0 [Note] InnoDB: Loading buffer pool(s) from /dsj/data/ib_buffer_pool
2021-06-08T08:01:04.605209Z 0 [Note] Plugin 'FEDERATED' is disabled.
2021-06-08T08:01:04.606509Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210608 16:01:04
2021-06-08T08:01:04.630046Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2021-06-08T08:01:04.630093Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2021-06-08T08:01:04.631031Z 0 [Warning] CA certificate ca.pem is self signed.
2021-06-08T08:01:04.631100Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2021-06-08T08:01:04.631249Z 0 [Note] Server hostname (bind-address): '*'; port: 3307
2021-06-08T08:01:04.631298Z 0 [Note] IPv6 is available.
2021-06-08T08:01:04.631314Z 0 [Note]   - '::' resolves to '::';
2021-06-08T08:01:04.631336Z 0 [Note] Server socket created on IP: '::'.
2021-06-08T08:01:04.646586Z 0 [Note] Event Scheduler: Loaded 0 events
2021-06-08T08:01:04.646733Z 1 [Note] Event Scheduler: scheduler thread started with id 1
2021-06-08T08:01:04.646892Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.33-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3307  MySQL Community Server (GPL)
2021-06-08T08:04:58.271324Z 3 [Note] Access denied for user 'root'@'localhost' (using password: YES)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值