MySQL is a database system that processes data using Structured Query Language. It’s one of the most widely used open-source database systems at the moment, which is frequently combined with PHP to build dynamic web pages. This article describes how to connect to MySQL from the command line using the MySQL program in cPanel accounts.
- Log in to your cPanel account.
- Access your Terminal from the cPanel dashboard under the ADVANCED section
- Type the following command on the Terminal, replacing your username with your MySQL username:
mysql -u username -p
- Enter your password at the Enter Password screen, and the
mysql> prompt appears.
How to connect to MySQL from the command line interface
Log in to your cPanel account and navigate to the Terminal section under the ADVANCED section.
Type in the following command on the Terminal, replacing the username with your username
mysql -u username -p
Enter your MySQL password at the Enter Password screen and hit Enter. If you enter the proper password, the mysql> prompt appears.
Enter the following command at the mysql> prompt to show a list of databases:
Make sure you do not forget the semicolon at the end of the statement with every MySQL command.
To access a specific database, type the following command at the mysql> prompt
The dbname should be replaced with the actual name of the database you need to access:
You can do much more SQL queries, and other operations after you access a database.
Congratulations, you have now learned how to connect to MySQL from the command line interface.
If you have any web hosting questions please feel free to reach out to us. We're happy to help.
Shared Hosting | Reseller Hosting | Managed WordPress Hosting | Fully Managed VPS Hosting
Our Guiding Principles
- Provide consistent, stable, and reliable web hosting services.
- Ensure rapid ticket response and quick resolutions to issues.
- Never saturate or over-provision servers to ensure stability and speed for our customers.
- Use only high-quality enterprise-class hardware to ensure minimal downtime from hardware failures.
- Provide clear pricing with no hidden fees or gotchas.