Of course, simply connecting to the MySQL server isn’t going to accomplish much. Chances are you will want to select a database to work with. This is accomplished in one of two ways:

  1. Including the name of the database along with the mysql connection command. For example, the command used to both connect to the MySQL server and select the mysql database is:
    %>mysql -u root -p mysql

    This might be misleading for some readers, as it seems as if the intent is to input mysql as the password. This is not correct. Take a moment to review the syntax as described in the mysql –help output, and it will be apparent that -u root -p actually comprise the [options] component of the syntax, and mysql comprises the [database] component.

  2. Once connected, select the database using the use command, as follows:
    mysql>use mydatabase

Once executed, all queries not explicitly specifying a database name will be directed towards the hypothetical mydatabase database.

Leave a Reply

Your email address will not be published. Required fields are marked *