How to connect remotely to mysql

Hi there,

Is there any way to connect to a my live database from mysql on a local machine? Can I just use the web address, database name, username and password? What is the mysql syntax for doing this?

thanks

Normally the live database would not be exposed publicly as this a security risk, and may be hosted on a different machine to your website.

If it is exposed the syntax would be something like:

mysql -u username -p dbserver.example.com dbname

You’ll be prompted for the password.

That said… why do you want to connect from your local?
hosts typically provide a HTML UI to access the database,
or you should ssh in and use the command line client from there.

Thanks for that :wink:

I had a mysql db at a hosting company that allowed remote access, never had any problems. You must open/forward the mysql tcp/ip port (normally 3306} through any routers/firewalls. And in mysql itself you have to allow your remote hosts to access the server, by default remote access is disabled.

Once set up you can use tools like heidi sql, mysql workbench, etc on your remote database.