Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » MySQL

The correct MySQL GRANT syntax

Submitted by on September 21, 2006 – 12:18 pm 5 Comments

It is surprising how many people run into problems trying to use the GRANT command: everything from not being able to access a database table to losing admin access to MySQL altogether. There’s a bunch of Web sites giving incorrect examples of using this command. Among these sites is, surprisingly, mysql.org. So, to save humanity, here’s my take on the GRANT issue and pay attention to the use of single and double quotes.

Example 1

Let’s say you want to create a new database called “my_drug_deals”, so you do this:

mysql -uroot -ppassword
mysql> CREATE DATABASE my_drug_deals ;
mysql> quit

Now, you want to connect to this DB as root from another machine and have full access. Here’s what you do:
mysql -uroot -ppassword
mysql> GRANT ALL PRIVILEGES ON my_drug_deals.* to root@'%' IDENTIFIED BY 'password' WITH GRANT OPTION ;
mysql> quit

This will make this database fully accessible to a “root” user connecting from ANY system, as long as the correct password is specified.

Print Friendly, PDF & Email

5 Comments »

  • xLittle21Yaox says:

    I forgot to file a grant W2, or whatever its called, and I already recieved my tax return. The grant is for $3000. It was paid directly to my school. Does this qualify as income? Will it affect my Earned Income Credit?

  • kerrin marz says:

    I relieved a call telling me the government approved me for a grant and they need $ 200 and some odd money for processing at weastern union . Is this a scam ?

  • Andres C says:

    What I mean is can they create agreements that their works cannot be resold, for example an oil paintings artist. Could he create an agreement restricting resale until after his death to allow him to control pricing while he is alive?

  • Praveen says:

    I want to know how to get a government grant to do loan modifications for free. I have heard of such programs but i cannnot really get information on it cause search engines are so cluttered with other stuff.

  • ali says:

    Better way is using any gui tools like dbforge studio for mysql rather than using mysql console to manage users and privileges.

1 Pingbacks »

Leave a Reply

%d bloggers like this: