To create second MySQL database and give privileges to the same user the following commands can be used:
# mysql -h localhost -u root -p mysql> SHOW CREATE DATABASE `database_name`; mysql> CREATE DATABASE `database_name2` /*!40100 DEFAULT CHARACTER SET utf8 */; mysql> SHOW GRANTS FOR database_user; mysql> GRANT ALL PRIVILEGES ON `database\_name2`.* TO 'database_user'@'%'; mysql> FLUSH PRIVILEGES; mysql> SHOW GRANTS FOR database_user; mysql> quit;
SHOW CREATE DATABASE `database_name`; will show first MySQL create database DDL SQL query.
CREATE DATABASE `database_name2` /*!40100 DEFAULT CHARACTER SET utf8 */; will create second MySQL database.
SHOW GRANTS FOR database_user; is used to view current user grants.
GRANT ALL PRIVILEGES ON `database\_name2`.* TO ‘database_user’@’%’; grant all privileges to newly created database;
FLUSH PRIVILEGES; will apply new user privileges.
SHOW GRANTS FOR database_user; is used to view updated user privileges;
quit; to exit MySQL client program.