How to Grant Access to a MySQL Database
MySQL is a database system that gives many people access to many databases. As the database administrator, you can grant access so that a new user can create, remove, update, and delete records. Stored data is inserted, updated, and queried using Standard Query Language; hence the name MySQL. MySQL users have several options for accessing the server that hosts the databases, including from the server itself, through the Internet, or remotely from an outside private network.
Instructions
-
-
1
Ascertain that the user to whom you want to grant access has already been created. Let's say that "Fred" is the new user name and the name has been created in your database.
-
2
Make sure you know the name of the database that you want Fred to have access to. Let's say the name of the database is "recruitment."
-
-
3
Get the Internet protocol address of the machine from which Fred will be accessing the database. If Fred will be accessing the database from the computer that the database is on, then the IP address would be "localhost" instead of a normal IP address.
-
4
Log on as the administrator to the MySQL database using your admin user name and password. The mysql prompt will appear.
-
5
Enter the command that grants user access to the database by typing the following:
GRANT ALL PRIVILEGES ON database.* to user@'host.'
Using the example of Fred, if he needs access to a database on his own computer, type the following:
GRANT ALL PRIVILEGES ON recruitment.* to fred@'localhost'.
Fred now has access to all tables in the recruitment database on his computer. If you want Fred to access the MySQL database from any machine, you can provide access from the 192.168.10.0 to 192.168.10.255 range of IP addresses by typing the following:
GRANT ALL PRIVILEGES on recruitment.* to fred@'192.168.10.0/255.255.255.0'
-
1
References
Resources
Comments
-
judlee
Apr 05, 2009
Granting access to a MySQL database has been a mystery to me. No longer! Thanks for adding to my education today.