一、升级前准备 1.1.Mysql提供mysql-shell验证方式,可以下载后进行验证: 下载shell验证文件: https://cdn.mysql.com/arcHives/mysql-shell/mysql-she
下载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=3306Socket=/tmp/mysql.sock[mysqld]log-bin=mysql-binserver-id=170character_set_server=utf8init_connect='SET NAMES utf8'#basedir=/usr/local/mysql#datadir=/usr/local/mysql/datasocket=/tmp/mysql.socklog-error=/var/log/mysqld.logpid-file=/run/mysqld/mysqld.pid#不区分大小写lower_case_table_names =1sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIONmax_connections=5000default-time_zone = '+8:00'max_allowed_packet = 32M#default_passWord_lifetime=90#wait_timeout=600# mysql8.0 addcollation-server=utf8_general_cibasedir=/usr/local/mysql8datadir=/usr/local/mysql/dataskip_ssldefault_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)# 确保数据都刷到硬盘上,更改成0mysql> 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 mysqlexport PATH=$PATH:/usr/local/mysql8/bin# 使环境变量生效[root@localhost] source /etc/profile
# 验证版本[root@localhost] which mysql/usr/local/mysql8/bin/mysql# 查看版本[root@localhost] mysql -Vmysql 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/mysql8datadir=/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 startStarting MySQL.. SUCCESS!
来源地址:https://blog.csdn.net/ArrogantB/article/details/126995829
--结束END--
本文标题: MySQL 5.7升级到8.0详细过程
本文链接: https://lsjlt.com/news/397478.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0