Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to connect mySql Database Remotely.But I cant.How can I do that?

I have tried like this:
C:>CD "Program FilesMySQLMySQL Server 4.1bin"

Keep in mind that your directory structure might differ from mine depending on how you installed MySQL. Also you may have to do a few “Clear Directories” (i.e. “CD” or CD..) to get to the base of C:>.
Type in:

mysql -u root -p

and enter in your root password when prompted.
If you logged in successfully, you should see:

mysql>

and if not, then you will get something like:

ERROR 1045 (28000): Access denied for user 'blah'@'localhost' (using password: YES)

Enter in

GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';

What this will do is create a new user with ROOT privileges, so be very careful what account you are creating. If you are just using the root account, then replace USERNAME with root. And just so we are clear, USERNAME is the account you wish to create or use. IP is the physical IP address of the computer you wish to grant remote access to. If you enter ‘%’ instead of an IP number, that user will be able to remote access the MySQL server from any computer. PASSWORD is the password you wish to create if it’s a new user or the existing password of an existing account. And yes, you need to use the single quotation.
And finally, you want to run this last command:

mysql> FLUSH PRIVILEGES;

To exit, just type:

mysql> quit;




but still I cant.Please give me solution.
Posted
Comments
[no name] 28-Mar-12 7:27am    
Let's see if I understand this, the database is located remotely but you are trying to access it from YOUR local C drive?

And CD means Change Directories not clear directories

There are several things you have to check.

If your DB engine is running on the same machine as your client does, you have to grant privileges to 'user'@'localhost'

If it's a real remote connection (client on other host as db is) you have to grant privileges just to 'user'.

The show grants command will show this as 'user'@'%'.

You also have to check the my.cnf config file. Look for line bind-address = 127.0.0.1 and comment it if you want to allow remote connections through all interfaces or use bind-address = <your server IP> to specify NIC.


regards
Michel
 
Share this answer
 
v3
Comments
markkuk 29-Mar-12 6:04am    
In addition to configuring MySQL, you will need to open firewalls and possibly set up port forwarding in your router.
Michel [mjbohn] 30-Mar-12 4:17am    
Yepp, you're right regarding firewalls, but I don't see an issue with routers.
Yaseer Arafat 7-Apr-12 15:56pm    
Michel How do I port forwarding in router?
Michel [mjbohn] 8-Apr-12 4:10am    
This depends on the router you're using. And you only need forwarding when you're doing NAT from private to public network.
Yaseer Arafat 8-Apr-12 12:23pm    
Thanks
Easy way
download mysql-workbench-gpl-5.2.38-win32 version
and install it

1)click on new connection and give the remote ip and db user name
connect with enter password

u will get the remote access ... :)
 
Share this answer
 
Comments
Michel [mjbohn] 28-Mar-12 7:47am    
No, not always that easy. See my solution.
ganeshbdas 29-Mar-12 8:45am    
This is vary vary easy methode
Michel [mjbohn] 30-Mar-12 4:27am    
Yes, workbench is an easy to use tool. But it is pretty useless if your DB is configured to reject login attempts from remote or your account is bound to connects from localhost.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900