Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Display help:
- `# mysql --help`
- Connect (Login):
- `# mysql -h <host> -u <user> -p<passwd>`
- Disconect (Logout):
- `mysql> exit`
- List all users:
- `mysql> select host, user, password from mysql.user;`
- Create user:
- `mysql> create user 'username'@'localhost' identified by 'password'`;
- `mysql> create user 'username'@'%' identified by 'password';` (for remote access)
- Change password:
- `mysql> set password for 'username@'hostname' = password('new_password');` or
- `mysql> update mysql.user set password=password('new_password') where user='username' and host='host-name'`;
- Grant permissions:
- `mysql> grant all privileges on *.* to 'username'@'localhost' with grant option;`
- `mysql> grant select, insert, delete on database_name.* to 'username'@'localhost';`
- List permissions:
- `mysql> show grants;`
- `mysql> show grants for 'username'@'localhost';`
- Revoke permissions:
- `mysql> revoke all privileges on database_name.* from 'username'@'localhost';`
- `mysql> revoke delete, drop on database_name.table_name from 'username'@'localhost';`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement