Controlling MySQL via Command Line Environment

For Linux hosting and all servers with Linux operating systems

It may be useful to test statements that are later executed by a script in the command line environment of the MySQL database. This is how you access your MySQL database via command line:

Step 1

Log in to your hosting package or server via SSH (with hosting packages e.g. Dual limited plus possible).

Step 2

Depending on the package, enter the command shown in the table below (replace the sample data with your MySQL access data):

Product Command
Webhosting (Shared Hosting) mysql -u dbo123456789 -h -p db123456789
Managed Server mysql -u dbo123456789 -h localhost -S /tmp/mysql5.sock -p db123456789
Server (without Plesk) mysql -u root -p
Server (with Plesk) mysql -u admin -p

Note: On servers with Plesk, the administrative database user has been renamed from root to admin. However, the password corresponds to the initial password of the server (root password).

Step 3

Log into your MySQL database.

Here is an example of a server with Plesk:


login as: root
root@'s password:
[root@u15376217 ~]# mysql -u admin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9342
Server version: 5.5.14 MySQL Community Server 5.5 (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 4

Now you can perform database operations on your MySQL databases via the command interface.