<!DOCTYPE html> <html> <head> </head> <body> <p>MySQL user management</p> <div style="color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium;"><br />Create a new user with password and set all permissions</div> <div style="color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium;"> <pre>CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES; </pre> <h2>How To Grant Different User Permissions</h2> <pre><br />Here is a short list of other common possible permissions that users can enjoy. </pre> <ul> <li>ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)</li> <li>CREATE- allows them to create new tables or databases</li> <li>DROP- allows them to them to delete tables or databases</li> <li>DELETE- allows them to delete rows from tables</li> <li>INSERT- allows them to insert rows into tables</li> <li>SELECT- allows them to use the Select command to read through databases</li> <li>UPDATE- allow them to update table rows</li> <li>GRANT OPTION- allows them to grant or remove other users' privileges</li> </ul> <pre><br />To provide a specific user with a permission, you can use this framework: </pre> <pre> GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’; </pre> <pre><br />If you want to give them access to any database or to any table, make sure to put an asterisk (*) in the place of the database name or table name.<br />Each time you update or change a permission be sure to use the Flush Privileges command.<br />If you need to revoke a permission, the structure is almost identical to granting it: </pre> <pre> REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’; </pre> <pre><br />Just as you can delete databases with DROP, you can use DROP to delete a user altogether: </pre> <pre> DROP USER ‘demo’@‘localhost’; </pre> <pre><br />To test out your new user, log out by typing </pre> <pre> quit </pre> <pre><br />and log back in with this command in terminal: </pre> <pre>mysql -u [username]-p<br /><br /><span style="color: #ff0000;"><strong>IF YOU SHOULD HAVE STILL PROBLEMS WITH PERMISSIONS: dpkg-reconfigure mysql-server </strong></span></pre> </div> </body> </html>
Subscribe
0 Comments
Oldest