mysql -u alice -p -h db.example.com mydb

Category: Databases & SQL

mysql -u alice -p -h db.example.com mydb

Connect to a remote MySQL database

mysql is MySQL and MariaDB's interactive client; -u names the user, -p prompts for the password, and -h the server host. The final argument selects the mydb database. Add -P for a custom port. Related: mysql -e for one-shot statements.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.