Showing posts with label Commandline. Show all posts
Showing posts with label Commandline. Show all posts

Thursday 25 September 2014

How to connect to MySQL from the command line?

Connect to MySQL from the command line

To connect to MySQL from the command line:

    Log in to your A2 Hosting account using SSH.
    At the command line, type the following command, replacing USERNAME with your username:

    mysql -u USERNAME -p

    At the Enter Password prompt, type your password. When you type the correct password, 
the mysql> prompt appears.

    To display a list of databases, type the following command at the mysql> prompt:

    show databases;

    To access a specific database, type the following command at the mysql> prompt, 
replacing DBNAME with the database that you want to access:

    use DBNAME;

    After you access a database, you can run SQL queries, list tables, and so on. Additionally:
        To view a list of MySQL commands, type help at the mysql> prompt.
        To exit the mysql program, type \q at the mysql> prompt.