Login and create a MySQL database with Linux command line

ORANGE COUNTY, Calif. -- This step-by-step illustration shows how to login and create a database from a Linux command line. We assume you have Apache + MySQL installed on a Linux server and have SSH access.

  1. Login to your server with SSH
  2. Start mySQL with the following command:
    //Replace [username] with the username for your mySQL
    mysql -u [username] -p
  3. Enter your password when prompted
  4. Now that you are logged into mySQL the command prompt will look like mysql>. Now you can type mySQL commands.
  5. Create a database:
    //Replace [foobar] with what ever you want
    create database [foobar];
  6. List all the databases:
    //Remember to end the statement with a semicolon
    show databases;
  7. Switch to a database so that you can look at its contents:
Add a Comment