赞
踩
下载shell验证文件:
https://cdn.mysql.com/archives/mysql-shell/mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
验证是否可以升级成功(验证的时候出现了几个错误没去处理,升级后倒时也没发现问题,如果是生产环境下还是要小心一些)
- # 验证mysql升级
- [root@localhost] tar -xf mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
- [root@localhost] cd mysql-shell-8.0.27-linux-glibc2.12-x86-64bit/bin
- [root@localhost] ./mysqlsh -uroot -p'123456' -S /tmp/mysql.sock -e "util.checkForServerUpgrade()"
- [root@localhost] mysqldump -uroot -p'123456' --all-databases --lock-tables=0 > all.sql.bak.20220412
- [root@localhost] mv all.sql.bak.20220412 /data/backup/mysql/
- 拉取软件包
- [root@localhost] wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar
-
- # 解压mysql8.0
- [root@localhost] tar zxvf mysql-8.0.21-el7-x86_64.tar.gz -C ../server/mysql3306/
-
- # 移动到指定目录
- [root@localhost] mv mysql-8.0.21-el7-x86_64 /usr/local/mysql8
-
- # 更改文件夹所属
- [root@localhost] chown -R mysql.mysql /usr/local/mysql8/
mysql8.0
部分,及sql_mode中的NO_ENGINE_SUBSTITUTION
- # 编辑配置文件
- [root@localhost] vim /etc/my.cnf
-
- [client]
- port=3306
- socket=/tmp/mysql.sock
-
- [mysqld]
- log-bin=mysql-bin
- server-id=170
- character_set_server=utf8
- init_connect='SET NAMES utf8'
- #basedir=/usr/local/mysql
- #datadir=/usr/local/mysql/data
- socket=/tmp/mysql.sock
- log-error=/var/log/mysqld.log
- pid-file=/run/mysqld/mysqld.pid
- #不区分大小写
- lower_case_table_names =1
-
- sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
-
- max_connections=5000
-
- default-time_zone = '+8:00'
- max_allowed_packet = 32M
- #default_password_lifetime=90
- #wait_timeout=600
-
- # mysql8.0 add
- collation-server=utf8_general_ci
- basedir=/usr/local/mysql8
- datadir=/usr/local/mysql/data
- skip_ssl
- default_authentication_plugin=mysql_native_password
- # 进入原mysql命令行
- [root@localhost] mysql -uroot -p'123456'
-
- # 查看mysql版本
- mysql> select version();
- +------------+
- | version() |
- +------------+
- | 5.7.26-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
cat /var/log/mysqld.log
解决后,再进入命令行- # 使用mysql8.0启动
- [root@localhost] /usr/local/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
-
-
- # 进入mysql命令行
- [root@localhost] mysql -uroot -p'123456'
- mysql> select version();
- +-----------+
- | version() |
- +-----------+
- | 8.0.27 |
- +-----------+
- 1 row in set (0.00 sec)
-
- mysql> exit;
- Bye
- [root@localhost] vim /etc/profile
-
- # add mysql
- export PATH=$PATH:/usr/local/mysql8/bin
-
- # 使环境变量生效
- [root@localhost] source /etc/profile
- # 验证版本
- [root@localhost] which mysql
- /usr/local/mysql8/bin/mysql
- # 查看版本
- [root@localhost] mysql -V
- mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
- [root@localhost] cp /usr/local/mysql8/support-files/mysql.server /etc/init.d/mysqld
- # 修改启动项目
- [root@localhost] vim /etc/init.d/mysqld
- # 修改目录位置
- basedir=/usr/local/mysql8
- datadir=/usr/local/mysql/data
-
- # 添加到启动列表
- [root@localhost] chkconfig --add mysqld
- # 刷新启动信息
- [root@localhost] systemctl daemon-reload
- # 查看启动项列表
- [root@localhost] chkconfig --list
重新启动服务器没有成功,启动的时候报错没有mysqld.pid文件,创建后启动成功
- # 重启动无法创建mysqld.pid文件处理方法
- [root@localhost] cat /var/log/mysqld.log
- [root@localhost] cd /run
- [root@localhost] mkdir mysqld
- [root@localhost] chown -R mysql.mysql ./mysqld
- [root@localhost] cd mysqld
- [root@localhost] touch mysqld.pid
- [root@localhost] chown -R mysql.mysql ./mysqld.pid
- [root@localhost] service mysqld start
-
- Starting MySQL.. SUCCESS!
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。