Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Display help:
  2.  
  3. `# mysql --help`
  4.  
  5. Connect (Login):
  6.  
  7. `# mysql -h <host> -u <user> -p<passwd>`
  8.  
  9. Disconect (Logout):
  10.  
  11. `mysql> exit`
  12.  
  13. List all users:
  14.  
  15. `mysql> select host, user, password from mysql.user;`
  16.  
  17. Create user:
  18.  
  19. `mysql> create user 'username'@'localhost' identified by 'password'`;
  20.  
  21. `mysql> create user 'username'@'%' identified by 'password';` (for remote access)
  22.  
  23. Change password:
  24.  
  25. `mysql> set password for 'username@'hostname' = password('new_password');` or
  26.  
  27. `mysql> update mysql.user set password=password('new_password') where user='username' and host='host-name'`;
  28.  
  29. Grant permissions:
  30.  
  31. `mysql> grant all privileges on *.* to 'username'@'localhost' with grant option;`
  32.  
  33. `mysql> grant select, insert, delete on database_name.* to 'username'@'localhost';`
  34.  
  35. List permissions:
  36.  
  37. `mysql> show grants;`
  38.  
  39. `mysql> show grants for 'username'@'localhost';`
  40.  
  41. Revoke permissions:
  42.  
  43. `mysql> revoke all privileges on database_name.* from 'username'@'localhost';`
  44.  
  45. `mysql> revoke delete, drop on database_name.table_name from 'username'@'localhost';`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement