Create a database and a user:
# mysql
> CREATE DATABASE $dbname;
> grant all on $dbname.* to '$dbname'@'localhost' identified by '<RANDOM_PASS>';
> FLUSH PRIVILEGES;
> QUIT;
Delete a database:
# mysql
> DROP DATABASE '$dbname';
Delete a user:
# mysql
> SHOW GRANTS FOR 'user'@'localhost';
or> SHOW GRANTS FOR 'user'@'127.0.0.1';
- Will show which grants a user have (should have one per DB and one USAGE)
> REVOKE ALL PRIVILEGES ON
$dbname.* FROM '$user'@'localhost';
- You should use REVOKE for every single GRANT listed before, except USAGE.
> DROP USER '$user'@'localhost';
> FLUSH PRIVILEGES;
Change a user's password:
# mysql
> SET PASSWORD FOR '$user'@'localhost' = PASSWORD('NeWpA$$w0rd');
Turn MyISAM into InnoDB tables
- List non InnoDB tables (includes MEMORY, CSV, PERFORMANCE_SCHEMA and probably
other engines):
# for i in $(echo "SHOW DATABASES;" | mysql); do echo "$i" ; echo 'SHOW TABLE STATUS where `engine`<>"InnoDB";' | mysql $i | cut -f 1,2 ; echo ; done |less
- Convert chosen tables
- (TODO: write this doc)