DB's and Users
Create a DB
CREATE DATABASE new_database;
Drop a DB
DROP DATABASE new_database;
Create a new user with all prems
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;
REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
Add user to 1 DB
GRANT ALL PRIVILEGES ON new_database . * TO 'newuser'@'localhost';
To drop a user:
DROP USER ‘newuser’@‘localhost’;
Innodb recovery
What we will need to do for the recovery is to stop mysql and put it in innodb_force_recovery to attempt to backup all databases.
service mysqld stop
mkdir /root/mysqlbak
cp -rp /var/lib/mysql/ib* /root/mysqlbak
vim /etc/my.cnf
You can start from 1 to 4, go up if it does not start and check mysql logs if it keeps crashing.
innodb_force_recovery = 1
service mysqld start
mysqldump -A > dump.sql
Drop all databases that needs recovery.
service mysqld stop
rm /var/lib/mysql/ib*
Comment out innodb_force_recovery in /etc/my.cnf
service mysqld start
Then check /var/lib/mysql/server/hostname.com.err to see if it creates new ib's.Then you can restore databases from the dump:mysql < dump.sql