Directly access a MySQL database from the terminal. Connect with the given username, password, and host straight from the command line. Know more about the common errors when connecting to MySQL database.
Requirements:
- MySQL
- MySQL User with Password
- MySQL Host
How To Connect To MySQL Database From The Command Line Terminal.
Step 1.
Open a shell and type the following.
Where.
- USERNAME is the user who has access to the database.
- HOST is the host where the MySQL Database Server is hosted.
Step 2.
Enter password on prompt.
Where.
- PASSWORD is the password of the user.
Result.
A successful login attempt will show a message similar to the following.
A login attempt with a wrong password, or incorrect username will show a message like below.
A login attempt without putting the required password will have a similar message like below.
Notes:
- The HOST option is optional.
- The default HOST is localhost
- Including the PASSWORD value on the command line is a security risk, prompt MySQL to require the password.
Leave a Reply