Home >> FAQs/Tutorials >> MySQL Tutorials >> Index

MySQL FAQs - Managing User Accounts and Access Privileges

By: FYIcenter.com

Part:   1  2  3   4  5  6 

(Continued from previous part...)

How To Delete a User Account?

If you want to delete a user account, you can connect to the server as "root" and use the "DROP USER ..." command to delete a user account. The tutorial exercise below shows you a good example:

>cd \mysql\bin
>mysql -u root -pretneciyf mysql

mysql> SELECT User, Password, Shutdown_priv FROM user;
+------+-------------------------------------------+-----+
| User | Password                                  | ... |
+------+-------------------------------------------+-----+
| root | *3735F1D8464342BA852E10101E55E422EBAAAF35 | Y   |
| dev  | *446BD97F308FBA0B9CBDC962C2842AD338BCE59E | N   |
+------+-------------------------------------------+-----+
2 rows in set (0.01 sec)

mysql> DROP USER dev;
Query OK, 0 rows affected (0.63 sec)

mysql> SELECT User, Password, Shutdown_priv FROM user;
+------+-------------------------------------------+-----+
| User | Password                                  | ... |
+------+-------------------------------------------+-----+
| root | *3735F1D8464342BA852E10101E55E422EBAAAF35 | Y   |
+------+-------------------------------------------+-----+
1 row in set (0.01 sec)

How To List All Existing User Accounts?

MySQL stores all existing user accounts in a table called "mysql.user". If you want see all user accoutns, you can use the "SELECT" command as shown in the tutorial exercise below:

>cd \mysql\bin
>mysql -u root -pretneciyf mysql

mysql> CREATE USER dba IDENTIFIED BY 'iyf';
Query OK, 0 rows affected (0.02 sec)

mysql> SELECT User, Password, Shutdown_priv FROM mysql.user;
+------+-------------------------------------------+-----+
| User | Password                                  | ... |
+------+-------------------------------------------+-----+
| root | *3735F1D8464342BA852E10101E55E422EBAAAF35 | Y   |
| dba  | *446BD97F308FBA0B9CBDC962C2842AD338BCE59E | N   |
+------+-------------------------------------------+-----+
2 rows in set (0.03 sec)

How To Rename an Existing User Account Name?

If you want to change the name of an existing user account, you can use the "RENAME USER oldName TO newName" command. The tutorial exercise below shows you how to do this:

>cd \mysql\bin
>mysql -u root -pretneciyf mysql

mysql> RENAME USER dev TO dba;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT User, Password, Shutdown_priv FROM mysql.user;
+------+-------------------------------------------+-----+
| User | Password                                  | ... |
+------+-------------------------------------------+-----+
| root | *3735F1D8464342BA852E10101E55E422EBAAAF35 | Y   |
| dev  | *446BD97F308FBA0B9CBDC962C2842AD338BCE59E | N   |
+------+-------------------------------------------+-----+
2 rows in set (0.03 sec)

(Continued on next part...)

Part:   1  2  3   4  5  6 


Selected Developer Jobs:

More...