MySQL Basics with a WE Application

How do I get access to my MySQL

Login as the shell user and type mysql at the command prompt. Your application MySQL user information is stored in .my.cnf and .mysql.passwd.

There are two users that are added to the MySQL instance for your application. One of them goes by the name w_user. w_user only has access to the database(s) that your application uses. The other user is admin. You use this user to manage your databases. For security purposes you should never use the admin user from within your application to access MySQL databases.

How to Create a MySQL Database

If you want to start over with your seed applications database

mysql> DROP DATABASE drupal;
mysql> CREATE DATABASE drupal;

The above is the simplest example. Generally speaking, each application comes with one database to host the application data. There are three other databases (displayed using the 'show databases' command) and these should not be modified directly unless you know what you are doing.

If you want to add a new database that is different from the ones that came with the application

mysql> DROP DATABASE databasename;
mysql> CREATE DATABASE databasename;

Be sure to substitute databasename with your preferred name.

How to Perform a Simple Backup of your Database

You may use the command mysqldump to output your database to a file that can be restored at a later date.

$ mysqldump --opt databasename > databasename.sql

The above will dump databasename to the file databasename.sql. It is wise to copy the database.sql file to another computer in case something happens to the application (i.e. the unlikely event that the application is broken into and destroyed).