Remote MySQL access from command line

This tutorial will walk you through setting up a user on your MySQL server to connect remotely.

You have access to login as the 'root' MySQL user
#mysql -u root -p
This will prompt you for your MySQL root password.

Once you are logged into MySQL you need to issue the GRANT command that will enable access for your remote user. In this example, user 'dbUser' that will have full access to the 'testDatabase' database.

mysql> GRANT ALL ON testDatabase.* TO [email protected]'remote_server_ip' IDENTIFIED BY 'dbUser_password';

This statement will grant ALL permissions to the user dbUser.

Now you can test your connection remotely. You can access your MySQL server from another Linux server:
mysql -h remote_server_ip -P 3306 -u <mysql_username> -d <db_name> -p

  • 0 Users Found This Useful
Was this answer helpful?