how to migrate from mysql to mariadb - without tears
TRANSCRIPT
![Page 1: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/1.jpg)
How to Migrate from MySQL to MariaDBwithout Tears
September 14-16, 2020
Sveta Smirnova
![Page 2: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/2.jpg)
• MySQL Support Engineer• Author of
• MySQL Troubleshooting• JSON UDF functions• FILTER clause for MySQL
• Speaker• Percona Live, OOW, Fosdem,
DevConf, HighLoad...
Sveta Smirnova
2
![Page 3: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/3.jpg)
•Initial Setup
•Authentication•Replication
•SQL Differences•Functional Differences•Diagnostics
Table of Contents
3
![Page 4: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/4.jpg)
• Started as fork of MySQL
• Independent product• Hundreds of unique features• Important improvements are backported
• from MySQL
MariaDB
4
![Page 5: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/5.jpg)
• Started as fork of MySQL• Independent product
• Hundreds of unique features• Important improvements are backported
• from MySQL
MariaDB
4
![Page 6: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/6.jpg)
• Started as fork of MySQL• Independent product• Hundreds of unique features
• Important improvements are backported• from MySQL
MariaDB
4
![Page 7: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/7.jpg)
• Started as fork of MySQL• Independent product• Hundreds of unique features• Important improvements are backported
• from MySQL
MariaDB
4
![Page 8: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/8.jpg)
Initial Setup
![Page 9: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/9.jpg)
• Check version compatibilityMySQL MariaDB
5.1 5.1, 5.2, 5.35.5 5.55.6 10.0, 10.15.7 10.2, 10.3, 10.4, 10.58.0 -
• Stop MySQL Server• Install MariaDB• Point MariaDB to MySQL datadir• Start MariaDB• Run mariadb-upgrade
Drop-in Replacement
6
![Page 10: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/10.jpg)
• Check version compatibility• Stop MySQL Server
• Install MariaDB• Point MariaDB to MySQL datadir• Start MariaDB• Run mariadb-upgrade
Drop-in Replacement
6
![Page 11: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/11.jpg)
• Check version compatibility• Stop MySQL Server• Install MariaDB
• Point MariaDB to MySQL datadir• Start MariaDB• Run mariadb-upgrade
Drop-in Replacement
6
![Page 12: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/12.jpg)
• Check version compatibility• Stop MySQL Server• Install MariaDB• Point MariaDB to MySQL datadir
• Start MariaDB• Run mariadb-upgrade
Drop-in Replacement
6
![Page 13: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/13.jpg)
• Check version compatibility• Stop MySQL Server• Install MariaDB• Point MariaDB to MySQL datadir• Start MariaDB
• Run mariadb-upgrade
Drop-in Replacement
6
![Page 14: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/14.jpg)
• Check version compatibility• Stop MySQL Server• Install MariaDB• Point MariaDB to MySQL datadir• Start MariaDB• Run mariadb-upgrade
Drop-in Replacement
6
![Page 15: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/15.jpg)
• Before upgrade$ ls -w100 data/mysql/
columns_priv.frm gtid_executed.ibd proc.MYD slow_log.CSV
columns_priv.MYD help_category.frm proc.MYI slow_log.frm
columns_priv.MYI help_category.ibd procs_priv.frm tables_priv.frm
db.frm help_keyword.frm procs_priv.MYD tables_priv.MYD
db.MYD help_keyword.ibd procs_priv.MYI tables_priv.MYI
db.MYI help_relation.frm proxies_priv.frm time_zone.frm
db.opt help_relation.ibd proxies_priv.MYD time_zone.ibd
engine_cost.frm help_topic.frm proxies_priv.MYI time_zone_leap_second.frm
engine_cost.ibd help_topic.ibd server_cost.frm time_zone_leap_second.ibd
event.frm innodb_index_stats.frm server_cost.ibd time_zone_name.frm
event.MYD innodb_index_stats.ibd servers.frm time_zone_name.ibd
event.MYI innodb_table_stats.frm servers.ibd time_zone_transition.frm
func.frm innodb_table_stats.ibd slave_master_info.frm time_zone_transition.ibd
...
System Database Changes
7
![Page 16: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/16.jpg)
• After upgrade$ ls -w100 data/mysql/
columns_priv.frm gtid_executed.ibd proc.frm slow_log.frm
columns_priv.MAD gtid_slave_pos.frm proc.MAD tables_priv.frm
columns_priv.MAI gtid_slave_pos.ibd proc.MAI tables_priv.MAD
column_stats.frm help_category.frm procs_priv.frm tables_priv.MAI
column_stats.MAD help_category.MAD procs_priv.MAD table_stats.frm
column_stats.MAI help_category.MAI procs_priv.MAI table_stats.MAD
db.frm help_keyword.frm proxies_priv.frm table_stats.MAI
db.MAD help_keyword.MAD proxies_priv.MAD time_zone.frm
db.MAI help_keyword.MAI proxies_priv.MAI time_zone_leap_second.frm
db.opt help_relation.frm roles_mapping.frm time_zone_leap_second.MAD
engine_cost.frm help_relation.MAD roles_mapping.MAD time_zone_leap_second.MAI
engine_cost.ibd help_relation.MAI roles_mapping.MAI time_zone.MAD
event.frm help_topic.frm server_cost.frm time_zone.MAI
...
System Database Changes
7
![Page 17: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/17.jpg)
• Specific MariaDB features• • Storage engines
• SQL statements• Options• Just use them
• Specific MySQL features• Features, present in both products
Differences
8
![Page 18: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/18.jpg)
• Specific MariaDB features• Specific MySQL features• • SQL statements
• Plugins• They are missed
• Features, present in both products
Differences
8
![Page 19: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/19.jpg)
• Specific MariaDB features• Specific MySQL features• Features, present in both products• • Working differently
• Our focus today
Differences
8
![Page 20: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/20.jpg)
Authentication
![Page 21: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/21.jpg)
• MySQL• –initialize• mysql_install_db deprecated, removed in 8.0
• MariaDB• Only mysql_install_db
Initial Setup
10
![Page 22: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/22.jpg)
• MySQL• –initialize• mysql_install_db deprecated, removed in 8.0
• MariaDB• Only mysql_install_db
Initial Setup
10
![Page 23: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/23.jpg)
• Supported plugins• MySQL
NativeCaching SHA-2 - Default in 8.0SHA-256CleartextNo-loginSocket Peer-Credential
• User management SQL is same• MariaDB supports multiple plugins per account
Authentication Plugins
11
![Page 24: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/24.jpg)
• Supported plugins• MariaDB
mysql_native_password
mysql_old_password
SHA-256 - Client only!ed25519GSSAPIPAMNamed PipeUnix Socket
• User management SQL is same• MariaDB supports multiple plugins per account
Authentication Plugins
11
![Page 25: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/25.jpg)
• Supported plugins• User management SQL is same
• MariaDB supports multiple plugins per account
Authentication Plugins
11
![Page 26: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/26.jpg)
• Supported plugins• User management SQL is same• MariaDB supports multiple plugins per account
Authentication Plugins
11
![Page 27: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/27.jpg)
• MySQL• validate_password plugin
Deprecated!
• validate_password componentmysql> SHOW VARIABLES LIKE ’validate_password%’;
+––––––––––––––––––––––––––––––––––––––+––––––––+
| Variable_name | Value |
+––––––––––––––––––––––––––––––––––––––+––––––––+
| validate_password_check_user_name | ON |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+––––––––––––––––––––––––––––––––––––––+––––––––+
• MariaDB• Password expiration works same way
Password Validation
12
![Page 28: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/28.jpg)
• MariaDB• Password Validation Plugin API• Two plugins
simple_password_check
MariaDB [performance_schema]> show variables like ’simple_password_check%’;
+–––––––––––––––––––––––––––––––––––––––––+–––––––+
| Variable_name | Value |
+–––––––––––––––––––––––––––––––––––––––––+–––––––+
| simple_password_check_digits | 1 |
| simple_password_check_letters_same_case | 1 |
| simple_password_check_minimal_length | 8 |
| simple_password_check_other_characters | 1 |
+–––––––––––––––––––––––––––––––––––––––––+–––––––+
4 rows in set (0.001 sec)
cracklib_password_check
MariaDB [performance_schema]> show variables like ’cracklib%’;
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
| Variable_name | Value |
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
| cracklib_password_check_dictionary | /var/cache/cracklib/cracklib_dict |
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
1 row in set (0.001 sec)
• Password expiration works same way
Password Validation
12
![Page 29: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/29.jpg)
• MariaDB• Password Validation Plugin API• Two plugins
cracklib_password_check
MariaDB [performance_schema]> show variables like ’cracklib%’;
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
| Variable_name | Value |
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
| cracklib_password_check_dictionary | /var/cache/cracklib/cracklib_dict |
+––––––––––––––––––––––––––––––––––––+–––––––––––––––––––––––––––––––––––+
1 row in set (0.001 sec)
• Password expiration works same way
Password Validation
12
![Page 30: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/30.jpg)
• MySQL• MariaDB• Password expiration works same way
Password Validation
12
![Page 31: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/31.jpg)
• Syntax is same
• MariaDB
• The role automatically available for the grantor
Roles
13
![Page 32: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/32.jpg)
• Syntax is same• MySQL
• Details are in Information SchemaADMINISTRABLE_ROLE_AUTHORIZATIONS
APPLICABLE_ROLES
ENABLED_ROLES
ROLE_COLUMN_GRANTS
ROLE_ROUTINE_GRANTS
ROLE_TABLE_GRANTS
• MariaDB
• The role automatically available for the grantor
Roles
13
![Page 33: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/33.jpg)
• Syntax is same• MySQL
• Stored in mysqluser
role_edges
mysql> select * from mysql.role_edges\G
*************************** 1. row ***************************
FROM_HOST: %
FROM_USER: my_role
TO_HOST: %
TO_USER: sveta
WITH_ADMIN_OPTION: N
1 row in set (0.00 sec)
default_roles
• MariaDB
• The role automatically available for the grantor
Roles
13
![Page 34: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/34.jpg)
• Syntax is same• MariaDB
• Details are in Information SchemaAPPLICABLE_ROLES
ENABLED_ROLES
• The role automatically available for the grantor
Roles
13
![Page 35: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/35.jpg)
• Syntax is same• MariaDB
• Stored in mysqluser
roles_mapping
MariaDB [information_schema]> select * from mysql.roles_mapping\G
*************************** 1. row ***************************
Host: localhost
User: root
Role: my_role
Admin_option: Y
*************************** 2. row ***************************
Host: %
User: sveta
Role: my_role
Admin_option: N
2 rows in set (0.001 sec)
• The role automatically available for the grantor
Roles
13
![Page 36: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/36.jpg)
• Syntax is same• MariaDB
• The role automatically available for the grantor
Roles
13
![Page 37: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/37.jpg)
Replication
![Page 38: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/38.jpg)
• Compatible• Can work any way around
• Unless data types are incompatible• Before 8.0!
No GTIDs
15
![Page 39: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/39.jpg)
• Compatible• Can work any way around• Unless data types are incompatible• Before 8.0!
No GTIDs
15
![Page 40: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/40.jpg)
• Implementation is different• MariaDB understands MySQL GTIDs• MySQL does not accept MariaDB GTIDs• Only replication from MySQL is possible!
GTIDs
16
![Page 41: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/41.jpg)
• Different concurrency control
• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 42: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/42.jpg)
• Different concurrency control• MySQL: slave_parallel_workers
• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 43: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/43.jpg)
• Different concurrency control• MySQL: slave_parallel_workers• MySQL: slave_parallel_type=DATABASE | LOGICAL_CLOCK
• MYSQL: binlog_transaction_dependency_tracking =
COMMIT_ORDER | WRITESET | WRITESET_SESSION
• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 44: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/44.jpg)
• Different concurrency control• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 45: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/45.jpg)
• Different concurrency control• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 46: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/46.jpg)
• Different concurrency control• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 47: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/47.jpg)
• Different concurrency control• MariaDB: slave_parallel_threads
• MariaDB: slave_parallel_max_queued
• MariaDB: slave_domain_parallel_threads
• MariaDB: slave_parallel_mode=optimistic | conservative |aggressive | minimal | none
Multi-threaded Replication
17
![Page 48: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/48.jpg)
• Different syntax for the source name• CHANGE MASTER
• MySQLCHANGE MASTER TO MASTER_HOST=’source1’ FOR CHANNEL ’source_1’;
• MariaDBCHANGE MASTER ’source_1’ TO MASTER_HOST=’source1’;
Multi-source Replication
18
![Page 49: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/49.jpg)
• Different syntax for the source name• Slave status
• MySQLSHOW SLAVE STATUS FOR CHANNEL ’source1’;
SELECT * FROM performance_schema.replication_connection_status WHERE
CHANNEL_NAME=’source_1’;
Default is for all channels• MariaDB
SHOW SLAVE ’source_1’ STATUS
SHOW ALL SLAVES STATUS
Default is default connection
Multi-source Replication
18
![Page 50: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/50.jpg)
SQL Differences
![Page 51: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/51.jpg)
• MySQLmysql> explain analyze select * from ol where thread_id=10432 and site_id != 9939
-> order by id limit 3\G
*************************** 1. row ***************************
EXPLAIN: -> Limit: 3 row(s) (actual time=364.792..364.792 rows=0 loops=1)
-> Filter: ((ol.thread_id = 10432) and (ol.site_id <> 9939)) (cost=0.06 rows=3)
(actual time=364.789..364.789 rows=0 loops=1)
-> Index scan on ol using PRIMARY (cost=0.06 rows=33)
(actual time=0.417..337.585 rows=100000 loops=1)
• MariaDBMariaDB [test]> analyze select * from ol
-> where thread_id=10432 and site_id != 9939 order by id limit 3\G
*************************** 1. row ***************************
...
type: index
possible_keys: thread_id
key: PRIMARY
key_len: 4
ref: const
rows: 100000
r_rows: 100000.00
filtered: 8.96
r_filtered: 0.00
Extra: Using where
ANALYZE
20
![Page 52: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/52.jpg)
• MariaDBMariaDB [test]> analyze select * from ol
-> where thread_id=10432 and site_id != 9939 order by id limit 3\G
*************************** 1. row ***************************
...
type: index
possible_keys: thread_id
key: PRIMARY
key_len: 4
ref: const
rows: 100000
r_rows: 100000.00
filtered: 8.96
r_filtered: 0.00
Extra: Using where
ANALYZE
20
![Page 53: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/53.jpg)
• MySQLmysql> show processlist\G
*************************** 1. row ***************************
Id: 2
User: root
Host: localhost:41352
db: test
Command: Query
Time: 37
State: User sleep
Info: select sleep(100)
Rows_sent: 0
Rows_examined: 0
...
• MariaDB
EXPLAIN for Running Thread
21
![Page 54: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/54.jpg)
• MySQLmysql> explain for connection 2\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: NULL
partitions: NULL
type: NULL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: NULL
filtered: NULL
Extra: No tables used
1 row in set (0.00 sec)
• MariaDB
EXPLAIN for Running Thread
21
![Page 55: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/55.jpg)
• MariaDBMariaDB [(none)]> show processlist\G
*************************** 1. row ***************************
Id: 3
User: root
Host: localhost:51126
db: test
Command: Query
Time: 2
State: User sleep
Info: select sleep(30)
Progress: 0.000
EXPLAIN for Running Thread
21
![Page 56: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/56.jpg)
• MariaDBMariaDB [(none)]> show explain for 3\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: NULL
type: NULL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: NULL
Extra: No tables used
1 row in set, 1 warning (25.718 sec)
EXPLAIN for Running Thread
21
![Page 57: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/57.jpg)
• MariaDBMariaDB [(none)]> show processlist\G
*************************** 1. row ***************************
Id: 3
User: root
Host: localhost:51126
db: test
Command: Query
Time: 2
State: User sleep
Info: select sleep(40)
Progress: 0.000
...
MariaDB [(none)]> show explain for 3\G
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
EXPLAIN for Running Thread
21
![Page 58: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/58.jpg)
• MySQL• Only histograms• Collected on demand
• MariaDB• Histograms collected and used by default• Other
Collected on demandUsed by default
Histograms and Table-Independent Statistics
22
![Page 59: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/59.jpg)
• MySQL• Only histograms• Collected on demand
• MariaDB• Histograms collected and used by default• Other
Collected on demandUsed by default
Histograms and Table-Independent Statistics
22
![Page 60: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/60.jpg)
Functional Differences
![Page 61: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/61.jpg)
• MySQL• Special data type• Functions, not available in MariaDB
JSON_OVERLAPS
JSON_PRETTY
JSON_STORAGE_FREE
JSON_STORAGE_SIZE
JSON_TABLE
• MariaDB• Replication
• Statement-based works fine• Row-based
Convert MySQL JSON data type to LONGTEXT
JSON
24
![Page 62: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/62.jpg)
• MySQL• MariaDB
• Data type JSON mapped to LONGTEXTCHECK (JSON_VALID(...)) automatically enabled if JSON alias is used
• Functions, not available in MySQLJSON_COMPACT
JSON_DETAILED
JSON_EXISTS
JSON_LOOSE
JSON_QUERY
JSON_VALUE
• Replication• Statement-based works fine• Row-based
Convert MySQL JSON data type to LONGTEXT
JSON
24
![Page 63: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/63.jpg)
• MySQL• MariaDB• Replication
• Statement-based works fine• Row-based
Convert MySQL JSON data type to LONGTEXT
JSON
24
![Page 64: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/64.jpg)
• "SQL with Geometry Types" of OGC• Both MySQL and MariaDB
• Not all MySQL GIS functions are in MariaDB
GIS
25
![Page 65: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/65.jpg)
• MySQL• Full Unicode support since 8.0.4
ICU library
• Extended regex syntax
• MariaDB• Full Unicode support since 10.5• PCRE syntax
• REGEXP_LIKE only in MySQL
Regular Expressions
26
![Page 66: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/66.jpg)
• MySQL• Full Unicode support since 8.0.4
ICU library
• Extended regex syntax• MariaDB
• Full Unicode support since 10.5• PCRE syntax
• REGEXP_LIKE only in MySQL
Regular Expressions
26
![Page 67: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/67.jpg)
• MySQL• Full Unicode support since 8.0.4
ICU library
• Extended regex syntax• MariaDB
• Full Unicode support since 10.5• PCRE syntax
• REGEXP_LIKE only in MySQL
Regular Expressions
26
![Page 68: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/68.jpg)
• Character set gb18030 only in MySQL• MariaDB has more collations• MariaDB supports not all MySQL collations
Localization
27
![Page 69: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/69.jpg)
Diagnostics
![Page 70: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/70.jpg)
• MySQL• In Performance Schema
mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
-> FROM performance_schema.events_stages_current where event_name like ’%alter%’;
+––––––––––––––––––––––––––––––––––––––––––––––––––––––+––––––––––––––––+––––––––––––––––+
| EVENT_NAME | WORK_COMPLETED | WORK_ESTIMATED |
+––––––––––––––––––––––––––––––––––––––––––––––––––––––+––––––––––––––––+––––––––––––––––+
| stage/innodb/alter table (read PK and internal sort) | 488 | 8512 |
...
| stage/innodb/alter table (read PK and internal sort) | 9396 | 9396 |
+––––––––––––––––––––––––––––––––––––––––––––––––––––––+––––––––––––––––+––––––––––––––––+
1 row in set (0.00 sec)
• MariaDB
Progress for ALTER TABLE
29
![Page 71: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/71.jpg)
• MariaDB• In Information Schema
MariaDB [information_schema]> select stage, max_stage, progress
-> from processlist where info like ’alter table%’;
+–––––––+–––––––––––+––––––––––+
| stage | max_stage | progress |
+–––––––+–––––––––––+––––––––––+
| 1 | 2 | 46.881 |
...
| 1 | 2 | 68.103 |
...
| 1 | 2 | 83.452 |
+–––––––+–––––––––––+––––––––––+
1 row in set (0.001 sec)
Progress for ALTER TABLE
29
![Page 72: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/72.jpg)
• MariaDB• In SHOW PROCESSLIST
MariaDB [information_schema]> show processlist\G
*************************** 1. row ***************************
Id: 5
User: root
Host: localhost:53616
db: employees
Command: Query
Time: 4
State: copy to tmp table
Info: alter table salaries engine=innodb
Progress: 31.510
Progress for ALTER TABLE
29
![Page 73: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/73.jpg)
• MariaDB• In the supporting client
MariaDB [employees]> alter table salaries engine=innodb;
Stage: 1 of 2 ’copy to tmp table’ 73.4% of stage done
Progress for ALTER TABLE
29
![Page 74: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/74.jpg)
• Tables, which MariaDB misses• Locks
data_lock_waits
data_locks
MariaDB: in Information Schema SE_*
Performance Schema
30
![Page 75: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/75.jpg)
• Tables, which MariaDB misses• Variables
global_variables - MariaDB: in I_Ssession_variables - MariaDB: in I_Svariables_by_thread - MariaDB: do not existvariables_info - MariaDB: I_S.SYSTEM_VARIABLES
Performance Schema
30
![Page 76: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/76.jpg)
• Tables, which MariaDB misses• Replication
replication_applier_filters
replication_applier_global_filters
replication_applier_status_by_worker
replication_connection_status
MariaDB: SHOW SLAVE STATUS
Performance Schema
30
![Page 77: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/77.jpg)
• Tables, which MariaDB misses• Errors
events_errors_summary_by_account_by_error
events_errors_summary_by_host_by_error
events_errors_summary_by_thread_by_error
events_errors_summary_by_user_by_error
events_errors_summary_global_by_error
Performance Schema
30
![Page 78: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/78.jpg)
• Tables, which MariaDB misses• Statements histograms
events_statements_histogram_by_digest
events_statements_histogram_global
Performance Schema
30
![Page 79: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/79.jpg)
• Tables, which MariaDB misses• User-defined functions
user_defined_functions
MariaDB: mysql.func
Performance Schema
30
![Page 80: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/80.jpg)
• Tables, which MariaDB misses• Binary log status and LSN
log_status
MariaDB: SHOW MASTER STATUS and SHOW ENGINE INNODB STATUS
Performance Schema
30
![Page 81: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/81.jpg)
• Initial upgrade is straightforward• Feature differences are easily solvable• MariaDB has options which simplify migration• Migrate to explore all MariaDB advantages!
Conclusions
31
![Page 82: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/82.jpg)
• Migrating to MariaDB from MySQL
MariaDB vs MySQL: Features
Function Difference
Replication Compatibility Matrix
Optimizer Features Comparison Matrix
Spatial Support Matrix
More Details
32
![Page 83: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/83.jpg)
www.slideshare.net/SvetaSmirnova
twitter.com/svetsmirnova
github.com/svetasmirnova
Thank you!
33
![Page 84: How to Migrate from MySQL to MariaDB - without Tears](https://reader030.vdocument.in/reader030/viewer/2022032410/62329bcd666b96373f22d88a/html5/thumbnails/84.jpg)
DATABASE PERFORMANCEMATTERS