Wishlist 0 ¥0.00

Upgrading to MySQL 8.0

MySQL 8 uses a global data dictionary containing information about database objects in transactional tables. In previous versions, the dictionary data was stored in metadata files and non-transactional system tables. You need to upgrade your data directory  from the file-based structure to the data-dictionary structure.

Just like a downgrade, you can upgrade using two methods:

  • In-place upgrade
  • Logical upgrade

You also should check a few prerequisites before the upgrade.

Getting ready

  1. Check for obsolete datatypes or triggers that have a missing or empty definer or an invalid creation context:
 
shell> sudo mysqlcheck -u root -p --all-databases --check-upgrade
  1. There must be no partitioned tables that use a storage engine that does not have native partitioning support. To identify these tables, execute this query:
 
shell> SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE NOT IN ('innodb', 'ndbcluster') AND CREATE_OPTIONS LIKE '%partitioned%';

If there are any of these tables, change them to InnoDB:

 
mysql> ALTER TABLE table_name ENGINE = INNODB;

Or remove the partitioning:

 
mysql> ALTER TABLE table_name REMOVE PARTITIONING;
  1. There must be no tables in the MySQL 5.7 mysql system database that have the same name as a table used by the MySQL 8.0 data dictionary. To identify tables with those names, execute this query:
 
mysql> SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE LOWER(TABLE_SCHEMA) = 'mysql' and LOWER(TABLE_NAME) IN ('catalogs', 'character_sets', 'collations', 'column_type_elements', 'columns', 'events', 'foreign_key_column_usage', 'foreign_keys', 'index_column_usage', 'index_partitions', 'index_stats', 'indexes', 'parameter_type_elements', 'parameters', 'routines', 'schemata', 'st_spatial_reference_systems', 'table_partition_values', 'table_partitions', 'table_stats', 'tables', 'tablespace_files', 'tablespaces', 'triggers', 'version', 'view_routine_usage', 'view_table_usage');
  1. There must be no tables that have foreign key constraint names longer than 64 characters. To identify tables with constraint names that are too long, execute this query:
 
mysql> SELECT CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE LENGTH(CONSTRAINT_NAME) > 64;
  1. Tables not supported by MySQL 8.0, such as ndb, should be moved to InnoDB:
 
mysql> ALTER TABLE tablename ENGINE=InnoDB;

How to do it...

Just like the previous recipe, the following subsections will take you through the details with various systems, bundles, and so on. 

In-place upgrades

Here is an outline of the steps:

  1. Shut down the old MySQL version.
  2. Replace the old MySQL binaries or packages with the new ones (detailed steps for different types of installation methods are covered).
  3. Restart MySQL on the existing data directory.
  4. Run the mysql_upgrade utility.
  5. In the MySQL 5.7 server, if there are encrypted InnoDB tablespaces, rotate the keyring master key by executing this statement:
 
mysql> ALTER INSTANCE ROTATE INNODB MASTER KEY;

Here are the detailed steps:

  1. Configure your MySQL 5.7 server to perform a slow shutdown. With a slow shutdown, InnoDB performs a full purge and change buffer merge before shutting down, which ensures that the undo logs are empty and the data files are fully prepared in case of file format differences between releases. This step is the most important because, without it, you will end up with the following error:
 
[ERROR] InnoDB: Upgrade after a crash is not supported. 

This redo log was created with MySQL 5.7.18. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html:

 
mysql> SET GLOBAL innodb_fast_shutdown = 0;
  1. Shut down the MySQL server as described in the Starting or Stopping MySQL 8 section.

Upgrade the MySQL binaries or packages.

YUM-based systems
  1. Switch the repositories:
 
shell> sudo yum-config-manager --disable mysql57-community
shell> sudo yum-config-manager --enable mysql80-community
  1. Verify that mysql80-community is enabled:
 
shell> sudo yum repolist all | grep mysql8
mysql80-community/x86_64             MySQL 8.0 Community Server  enabled:     16
mysql80-community-source             MySQL 8.0 Community Server  disabled
  1. Run the yum update:
 
shell> sudo yum update mysql-server
APT-based systems
  1. Reconfigure the apt to switch to MySQl 8.0:
 
shell> sudo dpkg-reconfigure mysql-apt-config
  1. Run apt-get update:
 
shell> sudo apt-get update
  1. Remove the current version:
 
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y
shell> sudo apt-get autoremove
  1. Install MySQL 8:
 
shell> sudo apt-get update
shell> sudo apt-get install mysql-server
shell> sudo apt-get install libmysqlclient21
Using RPM or APT bundles

Uninstall the existing packages (refer to the Uninstalling MySQL 8 section) and install the new packages, which can be downloaded fromMySQL Downloads (refer to the Installing MySQL 8.0 using RPM or DEB files section).

Using Generic Binaries

If you have installed MySQL through binaries, you have to remove the symlink to the old version (refer to the Uninstalling MySQL 8 section) and do a fresh installation (refer to the Installing MySQL on Linux using generic binaries section).

Start the MySQL 8.0 server (refer to the Starting or Stopping MySQL 8 to start MySQL section). If there are encrypted InnoDB tablespaces, use the --early-plugin-load option to load the keyring plugin.

The server automatically detects whether data dictionary tables are present. If not, the server creates them in the data directory , populates them with metadata, and then proceeds with its normal startup sequence. During this process, the server upgrades metadata for all database objects, including databases, tablespaces, system and user tables, views, and stored programs (stored procedures and functions, triggers, event scheduler events). The server also removes files that previously were used for metadata storage. For example, after upgrading, you will notice that your tables no longer have .frm files.

The server creates a directory named backup_metadata_57 and moves the files used by MySQL 5.7 into it. The server renames the event and proc tables to event_backup_57 and proc_backup_57. If this upgrade fails, the server reverts all changes to the data directory. In this case, you should remove all redo log files, start your MySQL 5.7 server on the same data directory, and fix the cause of any errors. Then, perform another slow shutdown of the 5.7 server and start the MySQL 8.0 server to try again.

Run the mysql_upgrade utility:

 
shell> sudo mysql_upgrade -u root -p

mysql_upgrade examines all tables in all databases for incompatibilities with the current version of MySQL. It makes any remaining changes required in the mysql system database between MySQL 5.7 and MySQL 8.0, so that you can take advantage of new privileges or capabilities. mysql_upgrade also brings the performance schema, INFORMATION_SCHEMA, and sys schema objects up to date for MySQL 8.0.

Restart the MySQL server (refer to the Starting or Stopping MySQL 8 to start MySQL section).

Logical Upgrades

Here is an outline of the steps:

  1. Export existing data from the old MySQL version using mysqldump
  2. Install the new MySQL version
  3. Load the dump file into the new MySQL version
  4. Run the mysql_upgrade utility

Here are the detailed steps:

  1. You need to take a logical backup of the database (refer to Chapter 7, Backups for a quicker backup called mydumper):
 
shell> mysqldump -u root -p --add-drop-table --routines --events --all-databases --ignore-table=mysql.innodb_table_stats --ignore-table=mysql.innodb_index_stats --force > data-for-upgrade.sql
  1. Shut down the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  2. Install the new MySQL version (refer to the methods mentioned in the In-place upgrades section).
  3. Start the MySQL server (refer to the Starting or Stopping MySQL 8 section).
  4. Reset the temporary root password:
 
shell> mysql -u root -p
Enter password: **** (enter temporary root password from error log)

mysql> ALTER USER USER() IDENTIFIED BY 'your new password';
  1. Restore the backup (this may take a long time depending up on the size of the backup). Refer to Chapter 8, Restoring Data for a quick restoration method called myloader:
 
shell> mysql -u root -p --force < data-for-upgrade.sql
  1. Run the mysql_upgrade utility:
 
shell> sudo mysql_upgrade -u root -p
  1. Restart the MySQL server (refer to the Starting or Stopping MySQL 8 section).

MYSQL数据库导入大数据量sql文件失败的解决方案

MYSQL数据库导入大数据量sql文件失败的解决方案

1.在讨论这个问题之前首先介绍一下什么是“大数据量sql文件”。

导出sql文件。

选择数据库-----右击选择“转储SQL文件”-----选择"结构和数据"  。保存文件db_mras.sql文件。

2.导入sql文件。在MYSQL中新建数据库db_mras。选择数据库-----右击选择“运行SQL文件”-----选择文件db_mras.sql,运行。

现在发现运行失败,提示错误“MySQL server has gone away” 。针对该问题提出如下解决方案:

提示该错误意思是:客户端与mysql的链接断开了,原因一般为sql运行时间过长或者sql文件太大。

排查问题原因:

(1)mysql服务宕了

运行命令:show  global status like  'uptime';    如果uptime的值很大 表明最近mysql服务没有重启。  若日志也没有相关信息,表明服务没有重启过,可以排除这个可能了。

(2)mysql链接超时

运行命令:show global variables  like '%timeout'; 查看运行结果中wait_timeout的值,一般为28800。代表mysql在误操作28800秒之后链接会关闭。

(3)mysql文件过大

运行命令:show global variables  like 'max_allowed_packet';   查看运行结果max_allowed_packet的值 ,如果过小,需要调整大。

解决方法:

在mysql的my.ini文件末尾加如下几句话: wait_timeout=2880000;     interactive_time=2880000;    max_allowed_packet=16M;  

其中max_allowed_packet代表控制其缓存区的最大长度。 wait_timeout代表无操作链接等待时间。

修改完以上参数之后重启mysql服务。

查看是否修改成功:运行命令:show global variables  like '%timeout';      show global variables  like 'max_allowed_packet';

  小贴士:如果找不到my.ini文件可以运行命令:mysql --help|grep my.ini 来查找文件路径。  

注意:如果以上办法没有解决你的问题,你还需要查看你的mysql文件安装盘的空间是否足够。

怎样使用MySQL-Front成功导入数据库文件?

  如何使用MySQL-Front导入数据库文件?当下载完MySQL-Front,很多人都会开始思索怎样在实际的工作中运用,mysql的一大运用就是在处理数据库上,那么今天跟大家讲讲如何成功利用MySQL-Front导入数据库文件?

  1、下载MySQL-Front(中文版)之后,解压后双击进行安装,只需直接下一步即可完成。

  2、双击桌面上MySQL-Front图标运行主程序,在信息栏输入服务器地址(例cd535.gotoip.net),如下图所示:

怎样使用MySQL-Front成功导入数据库文件?_数据库_mysql导入文件_课课家

  3、在连接栏同样输入服务器地址(例cd535.gotoip.net),其它选项默认即可,如下图所示:

  4、在注册栏输入数据库用户名、数据库密码、数据库名,如下图所示:

  5、确定数据库信息输入无误点击打开远程连接,右键数据库选择“输入”以及“SQL文件”图标,然后再从本地电脑选择需要导入的SQL文件即可,如下图所示:

  附:MySQL-Front导入SQL文件不受大小限制,另外还可以导入Access文件、Excel文件、ODBC表格。

  万一不能正常导入也可以得到相关错误提示,有助于进一步排查故障原因。

  另:MySQL数据库备份文件较小,也可通过phpMyAdmin管理工具进入后点击“Import”进行导入。

mysql8.0数据导入mysql5.7问题解决

本地数据库是mysql8.0,但是腾讯云云数据库是mysql5.7,在导入的时候提示了如下错误:

"Warning: Using a password on the command line interface can be insecure.?ERROR 1273 (HY000) at line 7819: Unknown collation: 'utf8mb4_0900_ai_ci'?dumper err?""-17")

这是因为腾讯云云数据库mysql5.7不支持utf8mb4_0900_ai_ci字符集,所以就把数据库打开,搜索utf8mb4_0900_ai_ci,然后批量替换成:utf8_general_ci,然后再导入就行了。

如果原来数据库格式是utf8mb4,而要导入的数据库不支持utf8mb4,那就再把utf8mb4批量改成utf8就行。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.