How to connect to db4free database using 'mysql' command from the terminal
I am running MySQL 5.5 on Ubuntu 14.04. I can open and work with local databases using mysql in the terminal. I can also run phpMyAdmin and access the database on db4free.net on the browser. However i would like to know how to achieve the same (access the db4free DB) from the terminal using mysql command.
Thanks in advance.
2 Answers
Use this command
mysql -u <username> -p -h db4free.net 2 Assuming that the server allows remote access, from Mysql.com: MySQL :: MySQL 5.0 Reference Manual :: 4.2.2 Connecting to the MySQL Server, run this command:
mysql --host=<mysql_server_ip_address> --user=<mysql_username> --password <mysql_database_name>If the server doesn't use the default MySQL port (3306), append the --port argument to the command:
mysql --host=<mysql_server_ip_address> --port=<mysql_server_port> --user=<mysql_username> --password <mysql_database_name>Then enter your password and press Enter.
On a side note, you could even append the password directly to the command by using --password=<mysql_password> instead of --password, altough users on your system would be able to see it by running ps auxw, so see for yourself which method suits the most.