How do I connect to my database via SSH?
source link: https://help.dreamhost.com/hc/en-us/articles/214882998-How-do-I-connect-to-my-database-via-SSH-
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How do I connect to my database via SSH?
Connecting from a shell account
- To log in to your MySQL database, you'll need your database credentials. View the Finding your database credentials article for instructions. You can also find these in the panel under MySQL Databases.
- You'll then need a terminal to run the following command. You can do this in a Mac or Linux computer using the native terminal, or you could just log into your DreamHost web server instead via SSH. If you're on Windows, use PuTTY to connect to your DreamHost server, then run the following command.
- Make sure to use your actual credentials for the following variables:
- hostname - Your mysql hostname URL. It will appear like mysql.example.com.
- user - Your database username
- password - Your database username's password
- database - Your database name
[server]$ mysql -h hostname -u user -p database
- You are then prompted for your password to log in.
- Once logged in, your command prompt will change to the following:
mysql>
You cannot use "localhost" to connect to your database, as DreamHost's MySQL servers are separate from the regular web site servers.
MariaDB mysql client used on private servers (VPS)
If you have a VPS, MariaDB is used as the mysql client when connecting. All MySQL commands continue to function the same, the only difference is the text that appears when you originally connect to the database server. For example:
[server]$ mysql -h hostname -u username -ppassword database Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 38309156 Server version: 5.7.28-log Source distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [database]>
See also
Did this article answer your questions?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK