Description
First, login to MySQL with the root user:
# mysql -u root -p
Next, to see all your databases:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | phpbb3 | | samhain | | test | | visapps | | wikidb | +--------------------+ 7 rows in set (0.12 sec)
Get a list of all users in MySQL:
mysql> select User,Host from mysql.user; +-----------+----------------------------+ | User | Host | +-----------+----------------------------+ | wikiuser | % | | root | 127.0.0.1 | | apache | localhost | | invadmin | localhost | | invlec | localhost | | nagios | localhost | | root | localhost | | samhain | localhost | | wikiuser | localhost | | wikiuser | localhost.localdomain | | apache | aixserver1 | | invadmin | aixserver1 | | invlec | aixserver1 | | root | aixserver1.mydomain.com | +-----------+----------------------------+ 17 rows in set (0.16 sec)
To see the grants for a particular user:
mysql> show grants for root@'aixserver1.mydomain.com'; +--------------------------------------------------------------------------------------+ | Grants for root@aixserver1.mydomain.com | +--------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'aixserver1.mydomain.com' WITH GRANT OPTION | +--------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> show grants for samhain@localhost; +----------------------------------------------------------+ | Grants for samhain@localhoat | +----------------------------------------------------------+ | GRANT USAGE ON *.* TO 'samhain'@'localhost' | | GRANT UPDATE ON `samhain`.`log` TO 'samhain'@'localhost' | +----------------------------------------------------------+ 2 rows in set (0.00 sec)
|