Before you consider migrating your data from MySQL to another database you have to know which objects have to be migrated.
With this query you will find the objects to consider:
SELECT TABLE_SCHEMA AS `SCHEMA`, IF(TABLE_TYPE = \'BASE TABLE\', \'TABLE\', TABLE_TYPE) AS OBJECT_TYPE, TABLE_NAME AS `OBJECT_NAME`
, IFNULL(ENGINE, \'\') AS ENGINE, IFNULL(TABLE_ROWS, \'\') AS `ROWS`
, IFNULL(DATA_LENGTH, \'\') AS DATA_SIZE, IFNULL(INDEX_LENGTH, \'\') AS INDEX_SIZE
FROM information_schema.tables
WHERE TABLE_SCHEMA NOT IN (\'information_schema\', \'mysql\', \'performance_schema\', \'sys\')
UNION
SELECT \'\', IF(is_role = \'Y\', \'ROLE\', \'USER\'), CONCAT(\"\'\", user, \"\'\", \'@\', \"\'\", host, \"\'\") AS OBJECT_TYPE, \'\', \'\', \'\', \'\'
FROM mysql.user
UNION
SELECT db, type, name, \'\', \'\', \'\', \'\'
FROM mysql.proc
WHERE db NOT IN (\'sys\', \'information_schema\', \'performance_schema\', \'mysql\')
UNION
SELECT db, \'EVENT\', name, \'\', \'\', \'\', \'\'
FROM mysql.event
UNION
SELECT trigger_schema, \'TRIGGER\', trigger_name, \'\', \'\', \'\', \'\'
FROM information_schema.triggers
UNION
SELECT db, \'EVENT\', name, \'\', \'\', \'\', \'\'
FROM mysql.event
ORDER BY `SCHEMA` ASC, OBJECT_TYPE ASC, OBJECT_NAME ASC
;
+--------+-------------+---------------------------+--------+---------+-----------+------------+
| SCHEMA | OBJECT_TYPE | OBJECT_NAME | ENGINE | ROWS | DATA_SIZE | INDEX_SIZE |
+--------+-------------+---------------------------+--------+---------+-----------+------------+
| | ROLE | \'test_r\'@\'\' | | | | |
| | USER | \'app\'@\'%\' | | | | |
| | USER | \'app\'@\'127.0.0.1\' | | | | |
| | USER | \'focmm\'@\'127.0.0.1\' | | | | |
| | USER | \'test\'@\'localhost\' | | | | |
| sbtest | TABLE | sbtest1 | InnoDB | 9680 | 2637824 | 163840 |
| test | EVENT | myevent | | | | |
| test | FUNCTION | format_time | | | | |
| test | PROCEDURE | diagnostics | | | | |
| test | TABLE | dt | InnoDB | 6 | 16384 | 0 |
| test | TABLE | test | InnoDB | 1045044 | 63520768 | 0 |
| test | TRIGGER | test_trigger | | | | |
| test | VIEW | test_v | | | | |
+--------+-------------+---------------------------+--------+---------+-----------+------------+
An easy way to dump all the object definitions (except users and roles) is the following command:
mysqldump --user=root --no-data --triggers --routines --events test > /tmp/test_structure_dump.sql
If you want to dump your data for importing them into another SQL database this command can help:
mysqldump --user=root --skip-extended-insert --skip-lock-tables --no-create-info
--where=\'id = id \' --skip-add-locks --skip-comments --skip-quote-names test test
| grep -v \'^/*\' | grep -v ^$ > /tmp/test_dump.sql
Migration of your data from one database to another appeared first on MariaDB.org
Before you consider migrating your data from MySQL to another database you have to know which objects have to be migrated.
With this query you will find the objects to consider:
SELECT TABLE_SCHEMA AS `SCHEMA`, IF(TABLE_TYPE = 'BASE TABLE', 'TABLE', TABLE_TYPE) AS OBJECT_TYPE, TABLE_NAME AS `OBJECT_NAME`
, IFNULL(ENGINE, '') AS ENGINE, IFNULL(TABLE_ROWS, '') AS `ROWS`
, IFNULL(DATA_LENGTH, '') AS DATA_SIZE, IFNULL(INDEX_LENGTH, '') AS INDEX_SIZE
FROM information_schema.tables
WHERE TABLE_SCHEMA NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
UNION
SELECT '', IF(is_role = 'Y', 'ROLE', 'USER'), CONCAT("'", user, "'", '@', "'", host, "'") AS OBJECT_TYPE, '', '', '', ''
FROM mysql.user
UNION
SELECT db, type, name, '', '', '', ''
FROM mysql.proc
WHERE db NOT IN ('sys', 'information_schema', 'performance_schema', 'mysql')
UNION
SELECT db, 'EVENT', name, '', '', '', ''
FROM mysql.event
UNION
SELECT trigger_schema, 'TRIGGER', trigger_name, '', '', '', ''
FROM information_schema.triggers
UNION
SELECT db, 'EVENT', name, '', '', '', ''
FROM mysql.event
ORDER BY `SCHEMA` ASC, OBJECT_TYPE ASC, OBJECT_NAME ASC
;
+--------+-------------+---------------------------+--------+---------+-----------+------------+
| SCHEMA | OBJECT_TYPE | OBJECT_NAME | ENGINE | ROWS | DATA_SIZE | INDEX_SIZE |
+--------+-------------+---------------------------+--------+---------+-----------+------------+
| | ROLE | 'test_r'@'' | | | | |
| | USER | 'app'@'%' | | | | |
| | USER | 'app'@'127.0.0.1' | | | | |
| | USER | 'focmm'@'127.0.0.1' | | | | |
| | USER | 'test'@'localhost' | | | | |
| sbtest | TABLE | sbtest1 | InnoDB | 9680 | 2637824 | 163840 |
| test | EVENT | myevent | | | | |
| test | FUNCTION | format_time | | | | |
| test | PROCEDURE | diagnostics | | | | |
| test | TABLE | dt | InnoDB | 6 | 16384 | 0 |
| test | TABLE | test | InnoDB | 1045044 | 63520768 | 0 |
| test | TRIGGER | test_trigger | | | | |
| test | VIEW | test_v | | | | |
+--------+-------------+---------------------------+--------+---------+-----------+------------+
An easy way to dump all the object definitions (except users and roles) is the following command:
mysqldump --user=root --no-data --triggers --routines --events test > /tmp/test_structure_dump.sql
If you want to dump your data for importing them into another SQL database this command can help:
mysqldump --user=root --skip-extended-insert --skip-lock-tables --no-create-info <br>
--where='id = id ' --skip-add-locks --skip-comments --skip-quote-names test test <br>
| grep -v '^/<br>*' | grep -v ^$ > /tmp/test_dump.sql
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | MySQL How do you restore tablespace | 0 | 7.63 | 13-07-2019 |
| 2 | Stored Procedures Instrumentation in MariaDB 10.5 | 0 | 13.84 | 11-10-2020 |
| 3 | MySQL Binlogs:: How to recover | 0 | 5.9 | 13-07-2019 |
| 4 | MySQL & Dockers…a simple set up | 0 | 5.87 | 15-03-2020 |
| 5 | Using your FRM file to get Schema and then import idb files.. | 0 | 4.63 | 12-11-2020 |
| 6 | How to Summarize gdb Backtrace with pt-pmp (and Flamegraph) | 0 | 6.06 | 10-02-2022 |
| 7 | The problem with MySQL foreign key constraints in Online Schema Changes | 0 | 6.63 | 17-03-2021 |
| 8 | Percona Live Europe Presents: Test Like a Boss | 0 | 4.93 | 25-09-2019 |
| 9 | Stop the senseless killing | 0 | 9.55 | 18-09-2022 |
| 10 | Sound Conveyors for Stealthy Data Transmission | 0 | 0 | 27-02-2025 |