当前位置: 首页 > news >正文

MySQL5.7升级到MySQL8.0的最佳实践分享

一、前言

事出必有因,在这个月的某个项目中,我们面临了一项重要任务,即每年一次的等保测评整改。这次测评的重点是Mysql的一些高危漏洞,客户要求我们无论如何必须解决这些漏洞。尽管我们感到无奈,但为了满足客户的要求,我们只能硬着头皮进行升级。而碰巧的是,Mysql5.710月份停止了更新,借着这次机会,我们决定研究一下Mysql5.7升级到Mysql8.0的过程。在本文的最后,我将分享一些在这次升级过程中遇到的问题。

升级需求:将5.7.43升级到8.0.34, 升级方式 in-place升级【关闭现有版本MySQL,将二进制或包替换成新版本并在现有数据目录上启动MySQL并执行升级任务的方式,称为in-place升级】

原版本

5.7.43CentOS Linux release 7.9.2009
新版本8.0.34CentOS Linux release 7.9.2009

二、Mysql 生命周期

以下Mysql 生命周期-内容来自于互联网

关于数据库版本升级,一直都是热议话题,对于升级的缘由各家也有所不同,有业务驱动的,有DBA自发驱动的,有规划导向也有方向指引的……抛开各种原因,当升级这个决定落下来的时候,对于DBA手头的几百几千套数据库来说,就好比是一场动物大迁徙,满满的画面感。

从Oracle发布的版本生命周期规划可以看到,Mysql5.7已经走到了生命周期的终点,意味着后续将不再为Mysql5.7提供官方更新、错误修复或安全补丁。

img

阿里云和AWS都在官方公布了版本支持计划,Mysql5.7版本已经开始了倒计时。

img

三、MySQL8.0的新特性

img

  • 默认字符集由latin1变为utf8mb4。
  • MyISAM系统表全部换成InnoDB表。
  • JSON特性增强。
  • 支持不可见索引,支持直方图。
  • sql_mode参数默认值变化。
  • 默认密码策略变更。
  • 新增角色管理。
  • 支持窗口函数,支持Hash join。

四、升级建议

  • 支持从MySQL5.7升级到MySQL8.0,注意仅支持GA版本之间的升级。
  • 不支持跨大版本的升级,如从5.6升级到8.0是不支持的。
  • 建议升级大版本前先升级到当前版本的最近小版本,如5.7先升级到5.7.43后再升级到8.0
  • 做好充足的备份! 数据无价!!!

五、升级前准备

5.1 Mysql-shell 检查工具兼容性

在执行升级操作前需要做一些检查工作,确认准备工作是否就绪,避免升级过程中出现异常。可以使用MySQL Shell使用util.checkForServerUpgrade进行检查,返回内容包括不符合迁移要求的问题,error的问题需要迁移前修改。

  • Mysql-shell 下载地址: https://dev.mysql.com/downloads/shell/

image-20231026094319303

选择 Archives ,查询更多版本

image-20231026094455783

选择当前最新的版本8.0.34,x84,64-bit

  • https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz

image-20231026101051586

 

#下载包

[root@srebro.cn ~]# wget https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz -C /root

[root@srebro.cn ~]# tar -xf mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz

[root@srebro.cn ~]# cd /root/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit/bin

[root@srebro.cn bin]# ./mysqlsh -uroot -p -S /tmp/mysql.sock -e "util.checkForServerUpgrade()" > util.checkForServerUpgrade.log

输出报告

 

The MySQL server at /tmp%2Fmysql.sock, version 5.7.39-log - MySQL Community

Server (GPL), will now be checked for compatibility issues for upgrade to MySQL

8.0.34...

1) Usage of old temporal type

No issues found

2) MySQL 8.0 syntax check for routine-like objects

No issues found

3) Usage of db objects with names conflicting with new reserved keywords

No issues found

4) Usage of utf8mb3 charset

Warning: The following objects use the utf8mb3 character set. It is

recommended to convert them to use utf8mb4 instead, for improved Unicode

support.

More information:

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html

mysql - schema's default character set: utf8

test - schema's default character set: utf8

5) Table names in the mysql schema conflicting with new tables in 8.0

No issues found

6) Partitioned tables using engines with non native partitioning

No issues found

7) Foreign key constraint names longer than 64 characters

No issues found

8) Usage of obsolete MAXDB sql_mode flag

No issues found

9) Usage of obsolete sql_mode flags

Notice: The following DB objects have obsolete options persisted for

sql_mode, which will be cleared during upgrade to 8.0.

More information:

https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals

global system variable sql_mode - defined using obsolete NO_AUTO_CREATE_USER

option

10) ENUM/SET column definitions containing elements longer than 255 characters

No issues found

11) Usage of partitioned tables in shared tablespaces

No issues found

12) Circular directory references in tablespace data file paths

No issues found

13) Usage of removed functions

No issues found

14) Usage of removed GROUP BY ASC/DESC syntax

No issues found

15) Removed system variables for error logging to the system log configuration

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-logging

16) Removed system variables

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed

17) System variables with new default values

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://mysqlserverteam.com/new-defaults-in-mysql-8-0/

18) Zero Date, Datetime, and Timestamp values

No issues found

19) Schema inconsistencies resulting from file removal or corruption

No issues found

20) Tables recognized by InnoDB that belong to a different engine

No issues found

21) Issues reported by 'check table x for upgrade' command

No issues found

22) New default authentication plugin considerations

Warning: The new default authentication plugin 'caching_sha2_password' offers

more secure password hashing than previously used 'mysql_native_password'

(and consequent improved client connection authentication). However, it also

has compatibility implications that may affect existing MySQL installations.

If your MySQL installation must serve pre-8.0 clients and you encounter

compatibility issues after upgrading, the simplest way to address those

issues is to reconfigure the server to revert to the previous default

authentication plugin (mysql_native_password). For example, use these lines

in the server option file:

[mysqld]

default_authentication_plugin=mysql_native_password

However, the setting should be viewed as temporary, not as a long term or

permanent solution, because it causes new accounts created with the setting

in effect to forego the improved authentication security.

If you are using replication please take time to understand how the

authentication plugin changes may impact you.

More information:

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-replication

23) Columns which cannot have default values

No issues found

24) Check for invalid table names and schema names used in 5.7

No issues found

25) Check for orphaned routines in 5.7

No issues found

26) Check for deprecated usage of single dollar signs in object names

No issues found

27) Check for indexes that are too large to work on higher versions of MySQL

Server than 5.7

No issues found

28) Check for deprecated '.<table>' syntax used in routines.

No issues found

Errors: 0

Warnings: 3

Notices: 1

NOTE: No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.

从输出报告可以看出,升级检查器在28个方面进行了检查,最终得出3个警告信息和1个提示。

消除警告:

  • Usage of utf8mb3 charset 在MySQL 8.0版本之前,默认字符集为latin1 ,utf8字符集指向的是utf8mb3 。从MySQL8.0开始,数据库的默认编码将改为utf8mb4 ;为了避免新旧对象字符集不一致的情况,可以在配置文件将字符集和校验规则设置为旧版本的字符集和比较规则。
  • New default authentication plugin considerations,密码认证插件变更。为了避免连接问题,可以仍采用5.7的mysql_native_password认证插件。

消除提示:

  • Usage of obsolete sql_mode flags: Mysq8.0 版本sql_mode不支持NO_AUTO_CREATE_USER,要避免配置的sql_mode中带有NO_AUTO_CREATE_USER

通过以上的例子,可以发现,MySQL Shell提供的升级检查工具能够帮助我们检测版本兼容性,减轻升级工作负担。

5.2 逻辑备份Mysql数据

 

which mysqldump

/home/application/mysql/app/bin/mysqldump

# --routines 备份存储过程和函数;--set-gtid-purged=OFF: 禁用GTID(全局事务标识);xxx1,XXX2 表示库名,备份多个库 用空格做为间隔

/home/application/mysql/app/bin/mysqldump -uroot -p --routines --set-gtid-purged=OFF --databases XXX1 XXX2 > /root/all-database-20231026.sql

5.3 优雅的停止数据库

# 进入原5.7 mysql命令行 正确关闭数据库
[root@srebro.cn ~]# mysql -uroot -p'srebro'mysql> select version();+------------+| version() |+------------+| 5.7.43-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

InnoDB 关闭模式。

如果值为 0,InnoDB 会在关闭前进行缓慢关闭、完全清除和更改缓冲区合并。

如果值为 1(默认值),InnoDB 会在关闭时跳过这些操作,这个过程称为快速关闭。

如果值为 2,InnoDB 刷新其日志并冷关机,就好像 MySQL 崩溃了;没有提交的事务丢失,但崩溃恢复操作使下一次启动需要更长的时间。 在仍然缓冲大量数据的极端情况下,缓慢关闭可能需要几分钟甚至几小时。

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> exitBye[root@cmdb ~]# ps -ef | grep mysqlroot 30990 30934 0 16:12 pts/0 00:00:00 grep --color=auto mysql

5.4 备份Mysql 数据目录,安装目录 和配置文件

--确认数据库状态为关闭状态
[root@srebro.cn ~]# systemctl status mysqld--数据目录备份[root@srebro.cn ~]# cp -r /home/application/mysql/data /home/application/mysql/data_bak_`date +%F`--安装目录备份[root@srebro.cn ~]# cp -r /home/application/mysql/app/ /home/application/mysql/app_bak_`date +%F`--配置文件备份[root@srebro.cn ~]# cp /etc/my.cnf /etc/my.cnf_`date +%F`

image-20231030140413635

5.5 下载并解压MySQL8

  • https://dev.mysql.com/downloads/

    image-20231026162251473

选择 Archives ,查询更多版本

image-20231026162331985

  • 下载地址: https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz 选择mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

image-20231026162932517

 

#执行以下步骤解压tar包:

# 安装包上传至原安装包目录下 我的是/home/application/mysql

[root@srebro.cn ~]# cd /home/application/mysql

[root@srebro.cn mysql]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

[root@srebro.cn mysql]# tar -xf mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

# 文件夹重命名为mysql8

[root@srebro.cn mysql]# mv mysql-8.0.34-linux-glibc2.12-x86_64 mysql8

# 更改文件夹所属

[root@srebro.cn mysql]# chown -Rf mysql:mysql /home/application/mysql/mysql8

# 删除安装包

[root@srebro.cn mysql]# rm -rf mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

六、升级

6.1 修改my.cnf 配置文件

因5.7版本与8.0版本参数有所不同,为了能顺利升级,我们需要更改部分配置参数。主要注意sql_modebasedir密码认证插件字符集设置,其他参数最好还是按照原5.7的来,不需要做调整。下面展示5.78.0的配置文件,注意备份原来配置文件

6.1.1 Mysql5.7_my.cnf 配置文件

 

[mysql]

socket=/tmp/mysql.sock

default-character-set=utf8

[mysqld]

user=mysql

basedir=/home/application/mysql/app

datadir=/home/application/mysql/data

character_set_server=utf8

collation-server=utf8_general_ci

#日志时间

log_timestamps=SYSTEM

port=3306

socket=/tmp/mysql.sock

max_connections=1000

max_allowed_packet=500M

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#慢日志

long_query_time=3

slow_query_log=ON

slow_query_log_file=/home/application/mysql/slow_query.log

#错误日志

log-error=/home/application/mysql/mysql-error.log

#binlog配置

server_id=150

log-bin=mysql-bin

max_binlog_size = 100M

binlog_format=row

log_slave_updates

expire_logs_days=7

#只能用IP地址检查客户端的登录,不用主机名

skip-name-resolve=1

6.1.2 Mysql8.0_my.cnf 配置文件

 

[mysql]

socket=/tmp/mysql.sock

default-character-set=utf8

[mysqld]

user=mysql

#日志时间

log_timestamps=SYSTEM

port=3306

socket=/tmp/mysql.sock

max_connections=1000

max_allowed_packet=500M

#只能用IP地址检查客户端的登录,不用主机名

skip-name-resolve=1

#binlog配置

server_id=150

log-bin=mysql-bin

max_binlog_size = 100M

binlog_format=row

log_slave_updates

expire_logs_days=7

#慢日志

long_query_time=3

slow_query_log=ON

slow_query_log_file=/home/application/mysql/slow_query.log

#错误日志

log-error=/home/application/mysql/mysql-error.log

#for8.0

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

basedir=/home/application/mysql/mysql8

datadir=/home/application/mysql/data

character_set_server=utf8

collation-server=utf8_general_ci

# 默认使用"mysql_native_password"插件认证

default_authentication_plugin=mysql_native_password

# 创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

6.2 执行升级程序

在mysql5.7升级的时候,MySQL启动后还需执行mysql_upgrade后重启MySQL。MySQL8.0.16开始,MySQL 不推荐使用mysql_upgrade; 直接使用 mysqld_safe 直接启动。关于--upgrade=的一些参数

  • --upgrade=AUTO MySQL升级所有过时的内容
  • --upgrade=NONE MySQL跳过升级步骤,可能会导致报错
  • --upgrade=MINIMAL MySQL在必要时升级数据字典表,information_schemainformation_schema。这可能会导致部分功能不能正常使用,例如MGR
  • --upgrade=FORCE MySQL会升级所有的内容,这会检查所有schema的所有对象,导致MySQL需要更长的时间启动。此模式下MySQL会重新创建系统表if they are missing
 

[root@srebro.cn ~]# /home/application/mysql/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --upgrade=FORCE

2023-10-30T07:33:23.595626Z mysqld_safe Logging to '/home/application/mysql/mysql-error.log'.

2023-10-30T07:33:23.620303Z mysqld_safe Starting mysqld daemon with databases from /home/application/mysql/data

会一直卡住不用担心

新开一个窗口,可观察下错误日志看是否报错/home/application/mysql/mysql-error.log然后登录数据库测试

 

[root@srebro.cn ~]# mysql -uroot -p'srebro'

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 12

Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.34 |

+-----------+

1 row in set (0.00 sec)

mysql>

6.3 修改Mysql环境变量

由于basedir 从/home/application/mysql/app 变成了 /home/application/mysql/mysql8,需要修改下环境变量信息:

 

[root@srebro.cn ~]# vim /etc/profile

export PATH=$PATH:/home/application/mysql/mysql8/bin

.......

#使环境变量生效

[root@srebro.cn ~]# source /etc/profile

#验证下mysql环境变量

#退出当前终端

[root@srebro.cn ~]# exit

[root@srebro.cn ~]# which mysql

/home/application/mysql/mysql8/bin/mysql

[root@srebro.cn ~]# mysql -V

mysql Ver 8.0.34 for Linux on x86_64 (MySQL Community Server - GPL)

6.4 停止mysqld_safe进程,使用systemd管理Mysql8

 

[root@cmdb ~]# kill -9 `ps -ef | grep mysql | awk '{print $2}'`

#确认没有mysql进程

[root@cmdb ~]# ps -ef | grep mysql

#使用systemd管理mysql8

#修改原先的ExecStart中,basedir的路径,改为mysql8 的路径

[root@cmdb ~]# vim /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/home/application/mysql/mysql8/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 65535

6.5 配置mysql8开机自启&启动mysql8

 

#reload下systemd

[root@cmdb ~]# systemctl daemon-reload

#加入开机自启动

[root@cmdb ~]# systemctl enable mysqld

Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /etc/systemd/system/mysqld.service.

#启动mysql8数据库

[root@cmdb ~]# systemctl start mysqld

[root@cmdb ~]# ps -ef | grep mysql

mysql 9497 1 36 14:59 ? 00:00:01 /home/application/mysql/mysql8/bin/mysqld --defaults-file=/etc/my.cnf

root 9544 8560 0 14:59 pts/0 00:00:00 grep --color=auto mysql

#登录数据库验证

[root@cmdb ~]# mysql -uroot -p'srebro'

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 8.0.34 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.34 |

+-----------+

1 row in set (0.00 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| srebro |

| sys |

| test |

+--------------------+

5 rows in set (0.00 sec)

mysql>

七、一些问题

7.1 问题一

在升级Mysql8.0后,关于JDBC中SSL连接的一些报错信息,如下图:

image-20231030161129369

image-20231030161421640

经排查发现,Mysql8.0 数据库默认开启了SSL认证,且之前Mysql5.7.39 也是默认开启了SSL认证,代码和JDBC驱动版本都没有变化,那很有可能就是Mysql8.0 中对于SSL的一个变化,咨询了DBA 朋友,专业的解释是,在5.7.31的时候SSL在源码中貌似没有真正的起作用,后面版本完善了这块的内容。倘若,不使用SSL去连接,就 需要按照如下的方法去处理:

  • 方法一: 从数据库成面,直接在my.cnf 中 添加skip_ssl 参数,从源头上关闭SSL 认证的方式
  • 方法二: 从代码层面,在JDBC 连接中,使用 &useSSL=false 参数,表示不使用SSL 认证

7.2 问题二

Mysql 报错unblock with ‘mysqladmin flush-hosts’,报错如下:

JDBC连接报错,报错内容 ERROR 1129 (HY000): Host ‘192.168.1.34’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

原因: 同一个ip在短时间内产生太多,中断的数据库连接而导致的阻塞;而中断的因为有些业务使用SSL去连接数据库,导致登录失败,登录被锁;

临时解决方法,使用mysqladmin flush-hosts 命令清理一下hosts文件,mysqladmin -u xxx -p flush-hosts,根本上去解决,就需要排查什么异常的连接导致阻塞,登录被锁,比如上面提到的SSL认证的问题。

八、参考

  • https://www.modb.pro/db/1715541568826990592
  • https://www.modb.pro/db/530848
  • https://www.modb.pro/db/1716302208709517312

一、前言

事出必有因,在这个月的某个项目中,我们面临了一项重要任务,即每年一次的等保测评整改。这次测评的重点是Mysql的一些高危漏洞,客户要求我们无论如何必须解决这些漏洞。尽管我们感到无奈,但为了满足客户的要求,我们只能硬着头皮进行升级。而碰巧的是,Mysql5.710月份停止了更新,借着这次机会,我们决定研究一下Mysql5.7升级到Mysql8.0的过程。在本文的最后,我将分享一些在这次升级过程中遇到的问题。

升级需求:将5.7.43升级到8.0.34, 升级方式 in-place升级【关闭现有版本MySQL,将二进制或包替换成新版本并在现有数据目录上启动MySQL并执行升级任务的方式,称为in-place升级】

原版本5.7.43CentOS Linux release 7.9.2009
新版本8.0.34CentOS Linux release 7.9.2009

二、Mysql 生命周期

以下Mysql 生命周期-内容来自于互联网

关于数据库版本升级,一直都是热议话题,对于升级的缘由各家也有所不同,有业务驱动的,有DBA自发驱动的,有规划导向也有方向指引的……抛开各种原因,当升级这个决定落下来的时候,对于DBA手头的几百几千套数据库来说,就好比是一场动物大迁徙,满满的画面感。

从Oracle发布的版本生命周期规划可以看到,Mysql5.7已经走到了生命周期的终点,意味着后续将不再为Mysql5.7提供官方更新、错误修复或安全补丁。

img

阿里云和AWS都在官方公布了版本支持计划,Mysql5.7版本已经开始了倒计时。

img

三、MySQL8.0的新特性

img

  • 默认字符集由latin1变为utf8mb4。
  • MyISAM系统表全部换成InnoDB表。
  • JSON特性增强。
  • 支持不可见索引,支持直方图。
  • sql_mode参数默认值变化。
  • 默认密码策略变更。
  • 新增角色管理。
  • 支持窗口函数,支持Hash join。

四、升级建议

  • 支持从MySQL5.7升级到MySQL8.0,注意仅支持GA版本之间的升级。
  • 不支持跨大版本的升级,如从5.6升级到8.0是不支持的。
  • 建议升级大版本前先升级到当前版本的最近小版本,如5.7先升级到5.7.43后再升级到8.0
  • 做好充足的备份! 数据无价!!!

五、升级前准备

5.1 Mysql-shell 检查工具兼容性

在执行升级操作前需要做一些检查工作,确认准备工作是否就绪,避免升级过程中出现异常。可以使用MySQL Shell使用util.checkForServerUpgrade进行检查,返回内容包括不符合迁移要求的问题,error的问题需要迁移前修改。

  • Mysql-shell 下载地址: https://dev.mysql.com/downloads/shell/

image-20231026094319303

选择 Archives ,查询更多版本

image-20231026094455783

选择当前最新的版本8.0.34,x84,64-bit

  • https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz

image-20231026101051586

 

#下载包

[root@srebro.cn ~]# wget https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz -C /root

[root@srebro.cn ~]# tar -xf mysql-shell-8.0.34-linux-glibc2.12-x86-64bit.tar.gz

[root@srebro.cn ~]# cd /root/mysql-shell-8.0.34-linux-glibc2.12-x86-64bit/bin

[root@srebro.cn bin]# ./mysqlsh -uroot -p -S /tmp/mysql.sock -e "util.checkForServerUpgrade()" > util.checkForServerUpgrade.log

输出报告

 

The MySQL server at /tmp%2Fmysql.sock, version 5.7.39-log - MySQL Community

Server (GPL), will now be checked for compatibility issues for upgrade to MySQL

8.0.34...

1) Usage of old temporal type

No issues found

2) MySQL 8.0 syntax check for routine-like objects

No issues found

3) Usage of db objects with names conflicting with new reserved keywords

No issues found

4) Usage of utf8mb3 charset

Warning: The following objects use the utf8mb3 character set. It is

recommended to convert them to use utf8mb4 instead, for improved Unicode

support.

More information:

https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html

mysql - schema's default character set: utf8

test - schema's default character set: utf8

5) Table names in the mysql schema conflicting with new tables in 8.0

No issues found

6) Partitioned tables using engines with non native partitioning

No issues found

7) Foreign key constraint names longer than 64 characters

No issues found

8) Usage of obsolete MAXDB sql_mode flag

No issues found

9) Usage of obsolete sql_mode flags

Notice: The following DB objects have obsolete options persisted for

sql_mode, which will be cleared during upgrade to 8.0.

More information:

https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals

global system variable sql_mode - defined using obsolete NO_AUTO_CREATE_USER

option

10) ENUM/SET column definitions containing elements longer than 255 characters

No issues found

11) Usage of partitioned tables in shared tablespaces

No issues found

12) Circular directory references in tablespace data file paths

No issues found

13) Usage of removed functions

No issues found

14) Usage of removed GROUP BY ASC/DESC syntax

No issues found

15) Removed system variables for error logging to the system log configuration

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-logging

16) Removed system variables

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed

17) System variables with new default values

To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary

More information:

https://mysqlserverteam.com/new-defaults-in-mysql-8-0/

18) Zero Date, Datetime, and Timestamp values

No issues found

19) Schema inconsistencies resulting from file removal or corruption

No issues found

20) Tables recognized by InnoDB that belong to a different engine

No issues found

21) Issues reported by 'check table x for upgrade' command

No issues found

22) New default authentication plugin considerations

Warning: The new default authentication plugin 'caching_sha2_password' offers

more secure password hashing than previously used 'mysql_native_password'

(and consequent improved client connection authentication). However, it also

has compatibility implications that may affect existing MySQL installations.

If your MySQL installation must serve pre-8.0 clients and you encounter

compatibility issues after upgrading, the simplest way to address those

issues is to reconfigure the server to revert to the previous default

authentication plugin (mysql_native_password). For example, use these lines

in the server option file:

[mysqld]

default_authentication_plugin=mysql_native_password

However, the setting should be viewed as temporary, not as a long term or

permanent solution, because it causes new accounts created with the setting

in effect to forego the improved authentication security.

If you are using replication please take time to understand how the

authentication plugin changes may impact you.

More information:

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-replication

23) Columns which cannot have default values

No issues found

24) Check for invalid table names and schema names used in 5.7

No issues found

25) Check for orphaned routines in 5.7

No issues found

26) Check for deprecated usage of single dollar signs in object names

No issues found

27) Check for indexes that are too large to work on higher versions of MySQL

Server than 5.7

No issues found

28) Check for deprecated '.<table>' syntax used in routines.

No issues found

Errors: 0

Warnings: 3

Notices: 1

NOTE: No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.

从输出报告可以看出,升级检查器在28个方面进行了检查,最终得出3个警告信息和1个提示。

消除警告:

  • Usage of utf8mb3 charset 在MySQL 8.0版本之前,默认字符集为latin1 ,utf8字符集指向的是utf8mb3 。从MySQL8.0开始,数据库的默认编码将改为utf8mb4 ;为了避免新旧对象字符集不一致的情况,可以在配置文件将字符集和校验规则设置为旧版本的字符集和比较规则。
  • New default authentication plugin considerations,密码认证插件变更。为了避免连接问题,可以仍采用5.7的mysql_native_password认证插件。

消除提示:

  • Usage of obsolete sql_mode flags: Mysq8.0 版本sql_mode不支持NO_AUTO_CREATE_USER,要避免配置的sql_mode中带有NO_AUTO_CREATE_USER

通过以上的例子,可以发现,MySQL Shell提供的升级检查工具能够帮助我们检测版本兼容性,减轻升级工作负担。

5.2 逻辑备份Mysql数据

 

which mysqldump

/home/application/mysql/app/bin/mysqldump

# --routines 备份存储过程和函数;--set-gtid-purged=OFF: 禁用GTID(全局事务标识);xxx1,XXX2 表示库名,备份多个库 用空格做为间隔

/home/application/mysql/app/bin/mysqldump -uroot -p --routines --set-gtid-purged=OFF --databases XXX1 XXX2 > /root/all-database-20231026.sql

5.3 优雅的停止数据库

 

# 进入原5.7 mysql命令行 正确关闭数据库

[root@srebro.cn ~]# mysql -uroot -p'srebro'

mysql> select version();

+------------+

| version() |

+------------+

| 5.7.43-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

InnoDB 关闭模式。

如果值为 0,InnoDB 会在关闭前进行缓慢关闭、完全清除和更改缓冲区合并。

如果值为 1(默认值),InnoDB 会在关闭时跳过这些操作,这个过程称为快速关闭。

如果值为 2,InnoDB 刷新其日志并冷关机,就好像 MySQL 崩溃了;没有提交的事务丢失,但崩溃恢复操作使下一次启动需要更长的时间。 在仍然缓冲大量数据的极端情况下,缓慢关闭可能需要几分钟甚至几小时。

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

[root@cmdb ~]# ps -ef | grep mysql

root 30990 30934 0 16:12 pts/0 00:00:00 grep --color=auto mysql

5.4 备份Mysql 数据目录,安装目录 和配置文件

 

--确认数据库状态为关闭状态

[root@srebro.cn ~]# systemctl status mysqld

--数据目录备份

[root@srebro.cn ~]# cp -r /home/application/mysql/data /home/application/mysql/data_bak_`date +%F`

--安装目录备份

[root@srebro.cn ~]# cp -r /home/application/mysql/app/ /home/application/mysql/app_bak_`date +%F`

--配置文件备份

[root@srebro.cn ~]# cp /etc/my.cnf /etc/my.cnf_`date +%F`

image-20231030140413635

5.5 下载并解压MySQL8

  • https://dev.mysql.com/downloads/

    image-20231026162251473

选择 Archives ,查询更多版本

image-20231026162331985

  • 下载地址: https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz 选择mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

image-20231026162932517

 

#执行以下步骤解压tar包:

# 安装包上传至原安装包目录下 我的是/home/application/mysql

[root@srebro.cn ~]# cd /home/application/mysql

[root@srebro.cn mysql]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

[root@srebro.cn mysql]# tar -xf mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

# 文件夹重命名为mysql8

[root@srebro.cn mysql]# mv mysql-8.0.34-linux-glibc2.12-x86_64 mysql8

# 更改文件夹所属

[root@srebro.cn mysql]# chown -Rf mysql:mysql /home/application/mysql/mysql8

# 删除安装包

[root@srebro.cn mysql]# rm -rf mysql-8.0.34-linux-glibc2.12-x86_64.tar.xz

六、升级

6.1 修改my.cnf 配置文件

因5.7版本与8.0版本参数有所不同,为了能顺利升级,我们需要更改部分配置参数。主要注意sql_modebasedir密码认证插件字符集设置,其他参数最好还是按照原5.7的来,不需要做调整。下面展示5.78.0的配置文件,注意备份原来配置文件

6.1.1 Mysql5.7_my.cnf 配置文件

 

[mysql]

socket=/tmp/mysql.sock

default-character-set=utf8

[mysqld]

user=mysql

basedir=/home/application/mysql/app

datadir=/home/application/mysql/data

character_set_server=utf8

collation-server=utf8_general_ci

#日志时间

log_timestamps=SYSTEM

port=3306

socket=/tmp/mysql.sock

max_connections=1000

max_allowed_packet=500M

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#慢日志

long_query_time=3

slow_query_log=ON

slow_query_log_file=/home/application/mysql/slow_query.log

#错误日志

log-error=/home/application/mysql/mysql-error.log

#binlog配置

server_id=150

log-bin=mysql-bin

max_binlog_size = 100M

binlog_format=row

log_slave_updates

expire_logs_days=7

#只能用IP地址检查客户端的登录,不用主机名

skip-name-resolve=1

6.1.2 Mysql8.0_my.cnf 配置文件

 

[mysql]

socket=/tmp/mysql.sock

default-character-set=utf8

[mysqld]

user=mysql

#日志时间

log_timestamps=SYSTEM

port=3306

socket=/tmp/mysql.sock

max_connections=1000

max_allowed_packet=500M

#只能用IP地址检查客户端的登录,不用主机名

skip-name-resolve=1

#binlog配置

server_id=150

log-bin=mysql-bin

max_binlog_size = 100M

binlog_format=row

log_slave_updates

expire_logs_days=7

#慢日志

long_query_time=3

slow_query_log=ON

slow_query_log_file=/home/application/mysql/slow_query.log

#错误日志

log-error=/home/application/mysql/mysql-error.log

#for8.0

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

basedir=/home/application/mysql/mysql8

datadir=/home/application/mysql/data

character_set_server=utf8

collation-server=utf8_general_ci

# 默认使用"mysql_native_password"插件认证

default_authentication_plugin=mysql_native_password

# 创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

6.2 执行升级程序

在mysql5.7升级的时候,MySQL启动后还需执行mysql_upgrade后重启MySQL。MySQL8.0.16开始,MySQL 不推荐使用mysql_upgrade; 直接使用 mysqld_safe 直接启动。关于--upgrade=的一些参数

  • --upgrade=AUTO MySQL升级所有过时的内容
  • --upgrade=NONE MySQL跳过升级步骤,可能会导致报错
  • --upgrade=MINIMAL MySQL在必要时升级数据字典表,information_schemainformation_schema。这可能会导致部分功能不能正常使用,例如MGR
  • --upgrade=FORCE MySQL会升级所有的内容,这会检查所有schema的所有对象,导致MySQL需要更长的时间启动。此模式下MySQL会重新创建系统表if they are missing
 

[root@srebro.cn ~]# /home/application/mysql/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --upgrade=FORCE

2023-10-30T07:33:23.595626Z mysqld_safe Logging to '/home/application/mysql/mysql-error.log'.

2023-10-30T07:33:23.620303Z mysqld_safe Starting mysqld daemon with databases from /home/application/mysql/data

会一直卡住不用担心

新开一个窗口,可观察下错误日志看是否报错/home/application/mysql/mysql-error.log然后登录数据库测试

 

[root@srebro.cn ~]# mysql -uroot -p'srebro'

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 12

Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.34 |

+-----------+

1 row in set (0.00 sec)

mysql>

6.3 修改Mysql环境变量

由于basedir 从/home/application/mysql/app 变成了 /home/application/mysql/mysql8,需要修改下环境变量信息:

 

[root@srebro.cn ~]# vim /etc/profile

export PATH=$PATH:/home/application/mysql/mysql8/bin

.......

#使环境变量生效

[root@srebro.cn ~]# source /etc/profile

#验证下mysql环境变量

#退出当前终端

[root@srebro.cn ~]# exit

[root@srebro.cn ~]# which mysql

/home/application/mysql/mysql8/bin/mysql

[root@srebro.cn ~]# mysql -V

mysql Ver 8.0.34 for Linux on x86_64 (MySQL Community Server - GPL)

6.4 停止mysqld_safe进程,使用systemd管理Mysql8

 

[root@cmdb ~]# kill -9 `ps -ef | grep mysql | awk '{print $2}'`

#确认没有mysql进程

[root@cmdb ~]# ps -ef | grep mysql

#使用systemd管理mysql8

#修改原先的ExecStart中,basedir的路径,改为mysql8 的路径

[root@cmdb ~]# vim /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/home/application/mysql/mysql8/bin/mysqld --defaults-file=/etc/my.cnf

6.5 配置mysql8开机自启&启动mysql8

 

#reload下systemd

[root@cmdb ~]# systemctl daemon-reload

#加入开机自启动

[root@cmdb ~]# systemctl enable mysqld

Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /etc/systemd/system/mysqld.service.

#启动mysql8数据库

[root@cmdb ~]# systemctl start mysqld

[root@cmdb ~]# ps -ef | grep mysql

mysql 9497 1 36 14:59 ? 00:00:01 /home/application/mysql/mysql8/bin/mysqld --defaults-file=/etc/my.cnf

root 9544 8560 0 14:59 pts/0 00:00:00 grep --color=auto mysql

#登录数据库验证

[root@cmdb ~]# mysql -uroot -p'srebro'

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 8.0.34 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.34 |

+-----------+

1 row in set (0.00 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| srebro |

| sys |

| test |

+--------------------+

5 rows in set (0.00 sec)

mysql>

七、一些问题

7.1 问题一

在升级Mysql8.0后,关于JDBC中SSL连接的一些报错信息,如下图:

image-20231030161129369

image-20231030161421640

经排查发现,Mysql8.0 数据库默认开启了SSL认证,且之前Mysql5.7.39 也是默认开启了SSL认证,代码和JDBC驱动版本都没有变化,那很有可能就是Mysql8.0 中对于SSL的一个变化,咨询了DBA 朋友,专业的解释是,在5.7.31的时候SSL在源码中貌似没有真正的起作用,后面版本完善了这块的内容。倘若,不使用SSL去连接,就 需要按照如下的方法去处理:

  • 方法一: 从数据库成面,直接在my.cnf 中 添加skip_ssl 参数,从源头上关闭SSL 认证的方式
  • 方法二: 从代码层面,在JDBC 连接中,使用 &useSSL=false 参数,表示不使用SSL 认证

7.2 问题二

Mysql 报错unblock with ‘mysqladmin flush-hosts’,报错如下:

JDBC连接报错,报错内容 ERROR 1129 (HY000): Host ‘192.168.1.34’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

原因: 同一个ip在短时间内产生太多,中断的数据库连接而导致的阻塞;而中断的因为有些业务使用SSL去连接数据库,导致登录失败,登录被锁;

临时解决方法,使用mysqladmin flush-hosts 命令清理一下hosts文件,mysqladmin -u xxx -p flush-hosts,根本上去解决,就需要排查什么异常的连接导致阻塞,登录被锁,比如上面提到的SSL认证的问题。

八、参考

  • https://www.modb.pro/db/1715541568826990592
  • https://www.modb.pro/db/530848
  • https://www.modb.pro/db/1716302208709517312

You have to work very hard to seem effortless.

你必须十分努力,才能看上去毫不费劲

© 版权声明

相关文章:

MySQL5.7升级到MySQL8.0的最佳实践分享

一、前言 事出必有因&#xff0c;在这个月的某个项目中&#xff0c;我们面临了一项重要任务&#xff0c;即每年一次的等保测评整改。这次测评的重点是Mysql的一些高危漏洞&#xff0c;客户要求我们无论如何必须解决这些漏洞。尽管我们感到无奈&#xff0c;但为了满足客户的要求…...

Rust 数据结构与算法:5栈:用栈实现前缀、中缀、后缀表达式

3、前缀、中缀和后缀表达式 计算机是从左到右处理数据的&#xff0c;类似(A (B * C))这样的完全括号表达式&#xff0c;计算机如何跳到内部括号计算乘法&#xff0c;然后跳到外部括号计算加法呢&#xff1f; 一种直观的方法是将运算符移到操作数外&#xff0c;分离运算符和操…...

作业day6

数据库 sqlite3 sq.db 如果sq.db存在则直接打开sq.db数据库&#xff0c;如果不存在则先创建再打开; ​ 系统命令 需要以 . 开头&#xff0c;不需要以 ; 结尾 .quit 退出数据库 .exit 退出数据库 .help 显示帮助信息&#xff0c;获取所有系统命令; ​ .table 查看当前数据…...

前方预警!2024年七大网络安全威胁

新颖创新技术的兴起和迅速采用已极大地改变了各行各业的全球网络安全和合规格局&#xff0c;比如生成式人工智能、无代码应用程序、自动化和物联网等新技术。 网络犯罪分子正转而采用新的技术、工具和软件来发动攻击&#xff0c;并造成更大的破坏。因此&#xff0c;《2023年网…...

绿色化 数据库 MongoDB 和 mysql 安装

绿色化 数据库 MongoDB 和 mysql 安装 【1.1】 前言 为什么要绿色化 安装呢&#xff1f;因为系统老升级&#xff0c;老重装&#xff01;&#xff01;也方便了解下数据库配置和库在那 绿色软件喜欢一般放在 D盘tools目录里 D:\tools\ 数据库 MongoDB D:\tools\MongoDB 数…...

npm install 一直卡着不动如何解决

目录 方式一&#xff1a;方式二&#xff1a; 方式一&#xff1a; npm cache clean --force npm config set registry https://registry.npmmirror.com npm install下面是简单的解释&#xff1a; &#x1f340;1、强制清理 npm 缓存 npm cache clean --force&#x1f340;2、设…...

电路设计(15)——篮球赛24秒违例倒计时报警器的proteus仿真

1.设计要求 设计、制作一个篮球赛24秒违例倒计时报警器。要求&#xff1a; &#xff08;1&#xff09;具有倒计时功能。可完整实现从“24”秒开始依序倒计时并显示倒计时过程&#xff0c;显示时间间隔为1秒。 &#xff08;2&#xff09;具有消隐功能。当“24”秒倒计时…...

golang 集成sentry:http.Client

http.Client 是 Go 标准库 HTTP 客户端实现&#xff0c; sentry-go也没有这个组件&#xff0c;所以需要自己实现。 我们只需要对 http.Transport 进行包装即可&#xff0c; 完整代码如下 package mainimport ("bytes""fmt""io""log"&…...

设计链表(不难,代码稍微多一点)

设计链表 在链表类中实现这些功能&#xff1a; get(index)&#xff1a;获取链表中第 index 个节点的值。如果索引无效&#xff0c;则返回-1。addAtHead(val)&#xff1a;在链表的第一个元素之前添加一个值为 val 的节点。插入后&#xff0c;新节点将成为链表的第一个节点。ad…...

[GXYCTF2019]禁止套娃

进来发现只有这句话&#xff0c;习惯性访问一下flag.php&#xff0c;发现不是404&#xff0c;那就证明flag就在这了&#xff0c;接下来要想办法拿到flag.php的源码。 这道题是.git文件泄露网页源码&#xff0c;githack拿到index.php源码 这里观察到多次判断&#xff0c;首先要…...

ubuntu下如何查看显卡及显卡驱动

ubuntu下如何查看显卡及显卡驱动 使用nvidia-smi 工具查看 查看显卡型号nvida-smi -L $ nvidia-smi -L GPU 0: NVIDIA GeForce RTX 3050 4GB Laptop GPU (UUID: GPU-4cf7b7cb-f103-bf56-2d59-304f8996e28c)当然直接使用nvida-smi 命令可以查看更多信息 $ nvidia-smi Mon Fe…...

【图论经典题目讲解】CF786B - Legacy 一道线段树优化建图的经典题目

C F 786 B − L e g a c y \mathrm{CF786B - Legacy} CF786B−Legacy D e s c r i p t i o n \mathrm{Description} Description 给定 1 1 1 张 n n n 个点的有向图&#xff0c;初始没有边&#xff0c;接下来有 q q q 次操作&#xff0c;形式如下&#xff1a; 1 u v w 表示…...

【AIGC】Stable Diffusion的采样器入门

在 Stable Diffusion 中&#xff0c;采样器&#xff08;Sampler&#xff09;是指用于生成图像的一种技术或方法&#xff0c;它决定了模型如何从潜在空间中抽样并生成图像。采样器在生成图像的过程中起着重要作用&#xff0c;影响着生成图像的多样性、质量和创造性。以下是对 St…...

【Python】通过conda安装Python的IDE

背景 系统&#xff1a;win11 软件&#xff1a;anaconda Navigator 问题现象&#xff1a;①使用Navigator安装jupyter notebook以及Spyder IDE 一直转圈。②然后进入anaconda prompt执行conda install jupyter notebook一直卡在Solving environment/-\。 类似问题&#xff1a; …...

基于HTML5实现动态烟花秀效果(含音效和文字)实战

目录 前言 一、烟花秀效果功能分解 1、功能分解 2、界面分解 二、HTML功能实现 1、html界面设计 2、背景音乐和燃放触发 3、燃放控制 4、对联展示 5、脚本引用即文本展示 三、脚本调用及实现 1、烟花燃放 2、燃放响应 3、烟花canvas创建 4、燃放声音控制 5、实际…...

「数据结构」栈和队列

栈 栈的基本概念 定义 栈是只允许在一端进行插入或删除操作的线性表栈顶&#xff1a;线性表允许进行插入删除的那一端栈底&#xff1a;固定的&#xff0c;不允许进行插入和删除的另一端空栈&#xff1a;不含任何元素特点&#xff1a;后进先出&#xff08;LIFO&#xff09; 基…...

【机器学习笔记】5 机器学习实践

数据集划分 子集划分 训练集&#xff08;Training Set&#xff09;&#xff1a;帮助我们训练模型&#xff0c;简单的说就是通过训练集的数据让我们确定拟合曲线的参数。 验证集&#xff08;Validation Set&#xff09;&#xff1a;也叫做开发集&#xff08; Dev Set &#xf…...

C++ //练习 7.5 在你的Person类中提供一些操作使其能够返回姓名和住址。这些函数是否应该是const的呢?解释原因。

C Primer&#xff08;第5版&#xff09; 练习 7.5 练习 7.5 在你的Person类中提供一些操作使其能够返回姓名和住址。这些函数是否应该是const的呢&#xff1f;解释原因。 环境&#xff1a;Linux Ubuntu&#xff08;云服务器&#xff09; 工具&#xff1a;vim 解释 姓名大概…...

python系统学习Day2

section3 python Foudamentals part one&#xff1a;data types and variables 数据类型&#xff1a;整数、浮点数、字符串、布尔值、空值 #整型&#xff0c;没有大小限制 >>>9 / 3 #3.0 >>>10 // 3 #3 地板除 >>>10 % 3 #1 取余#浮点型&#xff…...

学习笔记——ENM模拟

学习笔记——ENM模拟 文章目录 前言一、文献一1. 材料与方法1.1. 大致概念1.2. 生态模型的构建1.2.1. 数据来源&#xff1a;1.2.2. 数据处理&#xff1a;1.2.3. 模型参数优化&#xff1a; 1.3. 适生情况预测1.3.1. 预测模型构建1.3.2. 适生区划分 1.4. 模型的评估与验证 2. 结果…...

【Linux】shell脚本忽略错误继续执行

在 shell 脚本中&#xff0c;可以使用 set -e 命令来设置脚本在遇到错误时退出执行。如果你希望脚本忽略错误并继续执行&#xff0c;可以在脚本开头添加 set e 命令来取消该设置。 举例1 #!/bin/bash# 取消 set -e 的设置 set e# 执行命令&#xff0c;并忽略错误 rm somefile…...

Debian系统简介

目录 Debian系统介绍 Debian版本介绍 Debian软件源介绍 软件包管理工具dpkg dpkg核心指令详解 安装软件包 卸载软件包 查询软件包状态 验证软件包完整性 手动处理依赖关系 dpkg vs apt Debian系统介绍 Debian 和 Ubuntu 都是基于 Debian内核 的 Linux 发行版&#xff…...

《通信之道——从微积分到 5G》读书总结

第1章 绪 论 1.1 这是一本什么样的书 通信技术&#xff0c;说到底就是数学。 那些最基础、最本质的部分。 1.2 什么是通信 通信 发送方 接收方 承载信息的信号 解调出其中承载的信息 信息在发送方那里被加工成信号&#xff08;调制&#xff09; 把信息从信号中抽取出来&am…...

DIY|Mac 搭建 ESP-IDF 开发环境及编译小智 AI

前一阵子在百度 AI 开发者大会上&#xff0c;看到基于小智 AI DIY 玩具的演示&#xff0c;感觉有点意思&#xff0c;想着自己也来试试。 如果只是想烧录现成的固件&#xff0c;乐鑫官方除了提供了 Windows 版本的 Flash 下载工具 之外&#xff0c;还提供了基于网页版的 ESP LA…...

力扣-35.搜索插入位置

题目描述 给定一个排序数组和一个目标值&#xff0c;在数组中找到目标值&#xff0c;并返回其索引。如果目标值不存在于数组中&#xff0c;返回它将会被按顺序插入的位置。 请必须使用时间复杂度为 O(log n) 的算法。 class Solution {public int searchInsert(int[] nums, …...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

视频行为标注工具BehaviLabel(源码+使用介绍+Windows.Exe版本)

前言&#xff1a; 最近在做行为检测相关的模型&#xff0c;用的是时空图卷积网络&#xff08;STGCN&#xff09;&#xff0c;但原有kinetic-400数据集数据质量较低&#xff0c;需要进行细粒度的标注&#xff0c;同时粗略搜了下已有开源工具基本都集中于图像分割这块&#xff0c…...

AirSim/Cosys-AirSim 游戏开发(四)外部固定位置监控相机

这个博客介绍了如何通过 settings.json 文件添加一个无人机外的 固定位置监控相机&#xff0c;因为在使用过程中发现 Airsim 对外部监控相机的描述模糊&#xff0c;而 Cosys-Airsim 在官方文档中没有提供外部监控相机设置&#xff0c;最后在源码示例中找到了&#xff0c;所以感…...

RabbitMQ入门4.1.0版本(基于java、SpringBoot操作)

RabbitMQ 一、RabbitMQ概述 RabbitMQ RabbitMQ最初由LShift和CohesiveFT于2007年开发&#xff0c;后来由Pivotal Software Inc.&#xff08;现为VMware子公司&#xff09;接管。RabbitMQ 是一个开源的消息代理和队列服务器&#xff0c;用 Erlang 语言编写。广泛应用于各种分布…...

Python Einops库:深度学习中的张量操作革命

Einops&#xff08;爱因斯坦操作库&#xff09;就像给张量操作戴上了一副"语义眼镜"——让你用人类能理解的方式告诉计算机如何操作多维数组。这个基于爱因斯坦求和约定的库&#xff0c;用类似自然语言的表达式替代了晦涩的API调用&#xff0c;彻底改变了深度学习工程…...