Difference between revisions of "User Management (MySQL)"

Jump to navigation Jump to search
(Initial creation - content from MySQL page (now category))
 
 
Line 1: Line 1:
== Create Users and Grant/Revoke Privileges ==
== Create Users and Grant/Revoke Privileges ==
After making any changes to user privilages, you need to flush them to ensure they're applied...
To create a new user you need to specify the username, the location/IP address it will be connecting from (use <code>%</code> for any location), and their password
<source lang="mysql"> FLUSH PRIVILEGES; </source>
<source lang="mysql"> CREATE USER '<user>'@'localhost' identified by '<password>';</source>
 
You can then give permissions to that user
<source lang="mysql"> GRANT ALL ON <dayabase>.* TO '<user>'@'localhost';</source>


To give full privileges (including the ability to alter user accounts) to a new user coming from any location use;
Depending on the version of MySQL running you can do this in one command (note that the <code>WITH GRANT OPTION</code> allows the user to create more users and/or grant privileges to users).
<source lang="mysql"> GRANT ALL PRIVILEGES on <database>.* to '<user>'@'%' identified by '<password>' WITH GRANT OPTION; </source>
<source lang="mysql"> GRANT ALL PRIVILEGES on <database>.* to '<user>'@'%' identified by '<password>' WITH GRANT OPTION; </source>


Line 17: Line 20:
To remove/revoke a privilege from an existing user ''web-user'';
To remove/revoke a privilege from an existing user ''web-user'';
<source lang="mysql"> REVOKE SELECT ON webdb.* FROM 'web-user'@'localhost';</source>
<source lang="mysql"> REVOKE SELECT ON webdb.* FROM 'web-user'@'localhost';</source>
After making any changes to user privilages, you need to flush them to ensure they're applied...
<source lang="mysql"> FLUSH PRIVILEGES; </source>


== Delete Users ==
== Delete Users ==

Navigation menu