mirror of
https://github.com/MariaDB/server.git
synced 2025-10-25 18:38:00 +03:00
Add --system={all, users, plugins, udfs, servers, stats, timezones}
This will dump system information from the server in
a logical form like:
* CREATE USER
* GRANT
* SET DEFAULT ROLE
* CREATE ROLE
* CREATE SERVER
* INSTALL PLUGIN
* CREATE FUNCTION
"stats" is the innodb statistics tables or EITS and
these are dumped as INSERT/REPLACE INTO statements
without recreating the table.
"timezones" is the collection of timezone tables
which are important to transfer to generate identical
results on restoration.
Two other options have an effect on the SQL generated by
--system=all. These are mutually exclusive of each other.
* --replace
* --insert-ignore
--replace will include "OR REPLACE" into the logical form
like:
* CREATE OR REPLACE USER ...
* DROP ROLE IF EXISTS (MySQL-8.0+)
* CREATE OR REPLACE ROLE ...
* UNINSTALL PLUGIN IF EXISTS (10.4+) ... (before INSTALL PLUGIN)
* DROP FUNCTION IF EXISTS (MySQL-5.7+)
* CREATE OR REPLACE [AGGREGATE] FUNCTION
* CREATE OR REPLACE SERVER
--insert-ignore uses the construct " IF NOT EXISTS" where
supported in the logical syntax.
'CREATE OR REPLACE USER' includes protection against
being run as the same user that is importing the mysqldump.
Includes experimental support for dumping mysql-5.7/8.0
system tables and exporting logical SQL compatible with MySQL.
Updates mysqldump man page, including this information and
(removing obsolute bug reference)
Reviewed-by: anel@mariadb.org
121 lines
5.0 KiB
Plaintext
121 lines
5.0 KiB
Plaintext
diff --git a/mysql-test/r/mysqldump-system.result b/mysql-test/r/mysqldump-system.result
|
|
index 88cf950c621..5f8b579fa67 100644
|
|
--- a/mysql-test/r/mysqldump-system.result
|
|
+++ b/mysql-test/r/mysqldump-system.result
|
|
@@ -7,8 +7,6 @@
|
|
delete from mysql.user where host not in ('localhost');
|
|
flush privileges;
|
|
create user USER;
|
|
-install plugin /*M!100401 IF NOT EXISTS */ unix_socket soname 'auth_socket.so';;
|
|
-alter user USER identified via unix_socket;
|
|
CREATE ROLE role_1;
|
|
CREATE ROLE role_2 WITH ADMIN role_1;
|
|
GRANT SHOW DATABASES ON *.* TO role_1;
|
|
@@ -48,9 +46,8 @@
|
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
-INSTALL PLUGIN unix_socket SONAME 'auth_socket.so';
|
|
CREATE USER 'root'@'localhost';
|
|
-CREATE USER 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+CREATE USER 'USER'@'%';
|
|
SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
|
|
CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
|
|
GRANT mariadb_dump_import_role TO CURRENT_USER();
|
|
@@ -68,7 +65,7 @@
|
|
/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
|
|
GRANT role_1 TO 'USER'@'%';
|
|
GRANT role_2 TO 'USER'@'%';
|
|
-GRANT USAGE ON *.* TO 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+GRANT USAGE ON *.* TO 'USER'@'%';
|
|
/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
|
|
/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
|
|
GRANT role_2 TO 'role_1' WITH ADMIN OPTION;
|
|
@@ -168,8 +165,6 @@
|
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
-/*M!100401 UNINSTALL PLUGIN IF EXIST unix_socket */;
|
|
-INSTALL PLUGIN unix_socket SONAME 'auth_socket.so';
|
|
DELIMITER |
|
|
/*M!100101 IF current_user()="'root'@'localhost'" THEN
|
|
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT="Don't remove current user 'root'@'localhost''";
|
|
@@ -183,7 +178,7 @@
|
|
END IF */|
|
|
DELIMITER ;
|
|
/*!50701 DROP USER IF EXISTS 'USER'@'%' */;
|
|
-CREATE /*M!100103 OR REPLACE */ USER 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+CREATE /*M!100103 OR REPLACE */ USER 'USER'@'%';
|
|
SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
|
|
CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
|
|
GRANT mariadb_dump_import_role TO CURRENT_USER();
|
|
@@ -203,7 +198,7 @@
|
|
/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
|
|
GRANT role_1 TO 'USER'@'%';
|
|
GRANT role_2 TO 'USER'@'%';
|
|
-GRANT USAGE ON *.* TO 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+GRANT USAGE ON *.* TO 'USER'@'%';
|
|
/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
|
|
/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
|
|
GRANT role_2 TO 'role_1' WITH ADMIN OPTION;
|
|
@@ -304,9 +299,8 @@
|
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
-INSTALL PLUGIN unix_socket /*M!100401 IF NOT EXISTS */ SONAME 'auth_socket.so';
|
|
CREATE USER IF NOT EXISTS 'root'@'localhost';
|
|
-CREATE USER IF NOT EXISTS 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+CREATE USER IF NOT EXISTS 'USER'@'%';
|
|
SELECT COALESCE(CURRENT_ROLE(),'NONE') into @current_role;
|
|
CREATE ROLE IF NOT EXISTS mariadb_dump_import_role;
|
|
GRANT mariadb_dump_import_role TO CURRENT_USER();
|
|
@@ -324,7 +318,7 @@
|
|
/*!80001 ALTER USER 'root'@'localhost' DEFAULT ROLE NONE */;
|
|
GRANT role_1 TO 'USER'@'%';
|
|
GRANT role_2 TO 'USER'@'%';
|
|
-GRANT USAGE ON *.* TO 'USER'@'%' IDENTIFIED VIA unix_socket;
|
|
+GRANT USAGE ON *.* TO 'USER'@'%';
|
|
/*M!100005 SET DEFAULT ROLE 'role_2' FOR 'USER'@'%' */;
|
|
/*!80001 ALTER USER 'USER'@'%' DEFAULT ROLE 'role_2' */;
|
|
GRANT role_2 TO 'role_1' WITH ADMIN OPTION;
|
|
@@ -413,12 +407,12 @@
|
|
CHECKSUM TABLE mysql.user, mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
|
|
mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
|
|
Table Checksum
|
|
-mysql.user 205632094
|
|
+mysql.user 926820922
|
|
mysql.roles_mapping 3150178430
|
|
mysql.time_zone_transition 3895294076
|
|
-mysql.plugin 1520695737
|
|
+mysql.plugin 0
|
|
mysql.servers 2783974349
|
|
-mysql.func 3241572444
|
|
+mysql.func 310494789
|
|
mysql.innodb_table_stats 347867921
|
|
mysql.table_stats 664320059
|
|
# Opps....
|
|
@@ -442,12 +436,12 @@
|
|
CHECKSUM TABLE mysql.user, mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin,
|
|
mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats;
|
|
Table Checksum
|
|
-mysql.user 205632094
|
|
+mysql.user 926820922
|
|
mysql.roles_mapping 3150178430
|
|
mysql.time_zone_transition 3895294076
|
|
-mysql.plugin 1520695737
|
|
+mysql.plugin 0
|
|
mysql.servers 2783974349
|
|
-mysql.func 3241572444
|
|
+mysql.func 310494789
|
|
mysql.innodb_table_stats 347867921
|
|
mysql.table_stats 664320059
|
|
DROP FUNCTION IF EXISTS metaphon;
|
|
@@ -461,7 +455,6 @@
|
|
DROP ROLE role_2;
|
|
DROP ROLE role_1;
|
|
drop user USER;
|
|
-uninstall plugin unix_socket;
|
|
insert into mysql.user select * from backup_users;
|
|
flush privileges;
|
|
drop table backup_users;
|