How to connect to MySQL from the command line

MySQL is a popular database management system that powers a large portion of the web. Databases stored on HostPapa VPS servers can be managed using interfaces such as phpMyAdmin or using MySQL instructions entered into a command line window.

To connect to MySQL from the command line, you will first need to log in to your server via SSH. Follow the instructions presented in this HostPapa knowledge base document to log in to your server via SSH: How to connect to your server via Secure Shell (SSH).

SSH login

Once you’re logged in to your server, enter the following command, replacing [username] with your user name:

mysql -u [username] -p

MySQL login

Enter your password to proceed.

MySQL logged in

Note: if you wish to use the MySQL root account, you will need to change the password from the default, random root password created when your server is commissioned. To do so, log in to your server’s WHM dashboard and type “mysql” in the search bar, then select MySQL Root Password.

How to connect to MySQL from the command line

Create a new, strong password, then click Change Password to proceed.

Connect to MySQL from the command line

Find out more about WHM in this HostPapa knowledge base article: How to use Web Host Manager with your Reseller hosting plan.

You can now manage the databases stored on your server using the command line. To view a list of MySQL commands, type help. You can also refer to the following support document for more information about the MySQL command line: https://dev.mysql.com/doc/refman/5.7/en/mysql.html

When you wish to exit the MySQL command line, enter \q.

Quit MySQL

For further questions, or if you need help, please open a support ticket from your HostPapa Dashboard. Follow this link to learn how.

Related Articles

Get online with our affordable web hosting

Get online with our affordable web hosting

Learn more now
HostPapa Mustache