Wednesday, September 3, 2008

How to Access MySQL Database fom the Remote Location using Command Line

The is the way to access MySQL Database from the remote location using command line.

Before you access database from the remote location, you have to grant the permission to access database . (See How to Grant Permission )

then from remote location use following command

Syntax : mysql -h [IP Address of MySQL DB] -u [UserName] -p

IP Address of MySQL DB = IP Address of MySQL Server Machine

UserName = Username which granted in MySQL Server

Ex : mysql -h -u chamara -p

When you enter above command MySQL Server will ask have to submit password which you enter in granting permission phase.


Anonymous said...

hi Suminda Chamara Silva.
I've just tried out this syntax about "how to access mysql database from the remote location using command line" and it doesn't work at my computer.
I've written "mysql -h -u dachristoph -p". It says: "'mysql' is not recognized as an internal or external command, operable program or batch file.".

hope you can help me...


.... said...

First check you properly inserted your user name to relevant database.that mean you need to insert user name what you are using in normal data base use "root".then you can double check your IP address properly expose your remote machine.for that you can ping your db ip address from your remote machine.i think then this command will work.if it's not work pls let me know.