NetAdminTools.com
 
Categories:
GNU/Linux | Homebrew designs | Perl | Ruby | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | ERP | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Ruby
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·ERP
·REALbasic
·All Categories


Showing All Grants With MySQL
Topic:Database   Date: 2005-08-07
Printer Friendly: Print   Mobile View: mobile

spacerspacer
<<  <   >  >>

Subject

Users are identified with both a user and a host. If you want to show all of the grants for all users, you need to first look at the mysql.user table:

 
[usr-1@srv-1 ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10863 to server version: 4.1.10a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select User,Host from mysql.user;
+------+---------------------------+
| User | Host                      |
+------+---------------------------+
| are  | 10.10.10.10               |
| are  | 10.10.10.11               |
| are  | 10.50.100.0/255.255.255.0 |
| are  | 10.50.100.112             |
| are  | 10.50.100.2               |
|      | localhost                 |
| are  | localhost                 |
| root | localhost                 |
|      | srv-1.example.com |
| root | srv-1.example.com |
+------+---------------------------+
10 rows in set (0.00 sec)

Some of these permissions overlap. That is, the 10.50.100.0 entry include the other individual hosts. We can now show the grants for individual users:

mysql> show grants for are@'10.50.100.0/255.255.255.0';
+-----------------------------------------------------------------+
| Grants for [email protected]/255.255.255.0                        |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'are'@'10.50.100.0/255.255.255.0' 
IDENTIFIED BY PASSWORD '4bc9fc1d367a0b23' |
| GRANT ALL PRIVILEGES ON `arewedown`.* TO 'are'@'10.50.100.0/255.255.255.0' |
| GRANT ALL PRIVILEGES ON `mysql`.`arewedown` TO 'are'@'10.50.100.0/255.255.255.0'|
+-----------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> show grants for [email protected];
+--------------------------------------------------------------+
| Grants for [email protected]                                   |
+--------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'are'@'10.10.10.10'                    |
| GRANT ALL PRIVILEGES ON `arewedown`.* TO 'are'@'10.10.10.10' |
+--------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql>

For more information on the GRANT command for MySQL and associated commands, see this page.


People:
Places:
Things:
Times:





Please read our Terms of Use and our Privacy Policy
Microsoft, Windows, Windows Server are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2013 NetAdminTools.com