Posts Tagged ‘mariadb’

my: a command-line tool for MariaDB Clusters

I’ve posted the code for my MariaDB Cluster command-line tool called my. It does a bunch of stuff but the main purpose is to allow you to easily monitor replication cluster-wide while working in the shell. Here’s an example of this screen… hostname port cons u_cons role repl_detail lag gtid read_only master1 3306 7 0 ms […]

Bash: Count the number of databases in a gzip compressed mysqldump

A simple bash one-liner! ?View Code BASHgunzip -c /path/to/backup/mysqldump.sql.gz | grep -E "^CREATE DATABASE" | wc -l Breaking this down.. This prints the contents of a gzip compressed mysqldump to the terminal ?View Code BASHgunzip -c /path/to/backup/mysqldump.sql.gz Grep for lines that start with CREATE DATABASES… ?View Code BASHgrep -E "^CREATE DATABASE" Count the number of […]

MariaDB: subquery causes table scan

I got asked today to look at some slow queries on a MariaDB 10 instance. Here are the anonymized results of the investigation I did into this and how I solved the issue… There were a bunch of queries, expected to run very fast, that were taking 10-15 seconds to execute. The queries were all […]

Recover a single table from a mysqldump

I needed to recover the data, from a single table, from a mysqldump containing all the databases from an entire instance. A quick google yielded this result. This produced a nifty little sed one-liner… ?View Code BASHsed -n -e ‘/CREATE TABLE.*your_table_name/,/CREATE TABLE/p’ mysqldump_file.sql > your_table_name.sql I also wanted to import the data into a different […]

MariaDB Compound Statements Outside Stored Procedures

It’s always been a small annoyance that the MySQL / MariaDB flavour of SQL wouldn’t allow you to use if else logic or loops outside of a stored procedure or trigger. There were ways around  this but it’s not as nice if you’re coming from TSQL. This is rectified in MariaDB from 10.1.1. One thing that is […]