• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

Access to MySql

How do I restrict access to MySql.
I have full access but I want my college to have access only to certain tables.
I would like to use NaviCat to define this.
Also how can I allow my college to connect to the MySql from the internet. Now I can only connect from the localhost.
  • 2
3 Solutions
soffcecManagerAuthor Commented:
How can I tell MySql to allow connection from the Internet ?

I need example for the user MyUser who allow him to use only the datbase MyTable but no other databases and he may connect from the Internet.
You'll have to change some settings in the mysql config file.
This is usually located in /etc/mysql/my.cnf

find that file and then find the line which reads:

Open in new window

this is preventing mysql from accepting remote connections.
Comment out that line by placing a '#' sign like this:

Open in new window

(or remove that entire line altogether)

Do the same to a line that says:
bind-address =

Open in new window

This is your localhost, and this line forces mysql to accept only connections from localhost.

Then, you will need to grant remote access to that specific host ("your college").
This is done with a GRANT mysql statement, like this:
GRANT ALL PRIVILEGES ON *.* TO username@remotehost IDENTIFIED BY “password”;

Open in new window

You have to revise that and put in the privileges, username and remotehost (and password) you want.
if from the internet you are going to use, are you planning to allow it from a specific IP[This is recommended] ??  then you can do this

CREATE USER 'MyUser'@'<IP ADDRESS>' identified by 'myuser123';

how ever it is possible to allow access to the db from any IP [This is NOT Recommended]

CREATE USER 'MyUser'@'%' identified by 'myuser123';

Then to grant privileges to that user use this

grant ALL on MyTable.* to 'MyUser'@'<IP ADDRESS>'

Even in the above statement, the ALL can be changed to specific like only select or only insert ,etc.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now