Create, Delete, Export, Import, Optimize a MySQL database are common tasks that can be done with various tools, for example using PHPMyAdmin, a MySQL client, command line.
If you have access to the server you can do these tasks directly from Windows command line or Linux terminal.
mysql -u [username] -p[password] -e "CREATE DATABASE test CHARACTER SET utf8 COLLATE utf8_general_ci;"
It creates test database with a specific character set and collation, if they aren’t specified will be used the default.
mysql -u [username] -p[password] -e "DROP DATABASE test"
Delete the test database.
mysqldump -u [username] --password=[password] test > dumpdb.sql
Make the dump file called dumpdb.sql of the test database.
mysql -u [username] --password=[password] -D test < dumpdb.sql"
Import the dumpdb.sql dump file into test database.
mysqlcheck -u [username] --password=[password] -o test
Optimize test database.