1. Start a terminal session and become the superuser. (Type su at the prompt and then enter the root password.)
2. Now we'll access the MySQL server. Type:
The system prompts for the MySQL root password.
Once we are successfully logged in, the system prints a welcome message and displays the mysql prompt ... something like
Welcome to the MySQL monitor. Commands end with ; or \g.
Type 'help' for help.
3. Now we are ready for creating the database. Issue the command: (Note: The command ends with a semi-colon.)
4. Create an account
5. An important point to note is that this database is created by the root and so will not be accessible to any other user unless permitted by the root. Thus, in order to use this database from other account, We have to set the permissions by issuing the following command:
GRANT SELECT ON [dbname].[table_name] TO [username]@localhost;
6. Close the mysql session by typing quit at the prompt. Exit from superuser and come back to your account. (Type exit).
Execute MySQL statements from a text file
If the file is at e.g /sql/myscript.sql, we can load it into the [dbname] database using the following command from the command line:
Executing the file from within the MySQL command line shell. mysql>
Apply any changes on settings related to privileges without restarting MySQL