Cheat Sheet - MySQL

Create database

create database some_database;

Create new user

create user 'someone'@'%' identified by 'your-password';

Grant privileges

grant create, alter, drop, insert, update, delete, select, references on some_database.* to 'someone'@'%';

List all users

select user, host 
from mysql.user;

Count all tables in a database

-- Count number of tables 
select count(*)
from information_schema.tables
where table_schema = '<my-schema>'

-- Warning! Might return inaccurate results!
select TABLE_NAME, TABLE_ROWS
from information_schema.tables
where table_schema = '<my-schema>'

-- Count all rows in all tables 
SELECT SUM(TABLE_ROWS) 
     FROM INFORMATION_SCHEMA.TABLES 
     WHERE TABLE_SCHEMA = '<my-schema>';