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, under SQL Services, select MySQL Root Password.

WHS Change MySQL Root Password

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

MySQL Root Password Changed

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:

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