Snippets.page

Code snippets, tips, how-tos

MySQL user management from the command line


Home » Dev » MySQL user management from the command line

List or delete users from the command line.

MySQL stores the list of users in the mysql.user table. List of all databases are available in the mysql.db table.

Show list of MySQL users

# Show list of all users select user from mysql.user; # Show list of users assigned to a particular database select user from mysql.db where db='databasename';
Code language: PHP (php)

Show list of databases for a user

# Show a list of databases a particular user can manage select db from mysql.db where user='dbusername';
Code language: PHP (php)

Delete a user

# Delete an user from all MySQL users. 'dbusername' must exist. drop user dbusername@localhost;
Code language: PHP (php)

Author:

Categories:


Leave a Reply

Your email address will not be published.