Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
afcda8120a | ||
|
87d83959ea | ||
|
4c3c9a11a2 | ||
|
a0f7751aa3 |
|
@ -0,0 +1,7 @@
|
||||||
|
# $git stash
|
||||||
|
|
||||||
|
## Stashing 1 file
|
||||||
|
|
||||||
|
```
|
||||||
|
git stash push [-m <message>] [--] [<pathspec>...]
|
||||||
|
```
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Certbot renew certificate
|
||||||
|
|
||||||
|
## touch nginx config
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo certbot --nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
## certificate only
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo certbot certonly --nginx
|
||||||
|
```
|
|
@ -1,5 +1,4 @@
|
||||||
# Find all tables whose foreign key refers to the table/column
|
# Find all tables whose foreign key refers to the table/column
|
||||||
[SQL File](./src/branch/master/MySQL/sql/all_foreign_keys_to_table_or_column.sql)
|
|
||||||
|
|
||||||
## By table
|
## By table
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
# MySQL users actions
|
||||||
|
|
||||||
|
## Show users with hosts
|
||||||
|
|
||||||
|
```
|
||||||
|
SELECT User, Host FROM mysql.user;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check user privileges
|
||||||
|
|
||||||
|
```
|
||||||
|
SHOW GRANTS FOR 'someuser'@'somehost.somedomain';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create user
|
||||||
|
|
||||||
|
```
|
||||||
|
CREATE USER 'some_user'@'somehost.somedomain' IDENTIFIED BY 'some_password';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete user
|
||||||
|
|
||||||
|
```
|
||||||
|
DROP USER 'some_user'@'somehost.somedomain';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Granting privileges
|
||||||
|
|
||||||
|
### Grant all privileges
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'somehost.somedomain' WITH GRANT OPTION;
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant privilege on database 'some_db'
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT SELECT ON `some_db`.* TO 'some_user'@'somehost.somedomain';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant privilege on table 'some_db'.'some_table'
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT SELECT ON `some_db`.'some_table' TO 'some_user'@'somehost.somedomain';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant privilege to select and update some columns on table 'some_db'.'some_table'
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT SELECT (id, some_column), UPDATE (some_column) ON `some_db`.`some_table` TO 'some_user'@'somehost.somedomain';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant with inheritance
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DELETE ON `some_db`.* TO 'some_user'@'somehost' WITH GRANT OPTION;
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
**'WITH GRANT OPTION'** makes it possible to convey to others what is permitted to oneself.
|
||||||
|
|
||||||
|
## Revoking privileges
|
||||||
|
|
||||||
|
### Revoke privilege to select from database 'somedb'
|
||||||
|
|
||||||
|
```
|
||||||
|
REVOKE SELECT ON `somedb`.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges from user
|
||||||
|
|
||||||
|
```
|
||||||
|
ALL PRIVILEGES ON *.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges to database 'somedb' from user
|
||||||
|
|
||||||
|
```
|
||||||
|
ALL PRIVILEGES ON `somedb`.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges from user
|
||||||
|
|
||||||
|
```
|
||||||
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Change password
|
||||||
|
|
||||||
|
```
|
||||||
|
ALTER USER 'test_user'@'localhost' IDENTIFIED BY 'new_password';
|
||||||
|
```
|
11
Readme.md
11
Readme.md
|
@ -4,6 +4,11 @@ This is a repository with useful snippets of various kinds of code
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
- [MySQL](./src/branch/master/MySQL)
|
- [Git](./Git/)
|
||||||
- - [all_foreign_keys_to_table_or_column](./src/branch/master/MySQL/all_foreign_keys_to_table_or_column.md)
|
- - [stash](./Git/stash.md)
|
||||||
- - [identify_lock](./src/branch/master/MySQL/identify_lock.md)
|
- [Linux](./Linux/)
|
||||||
|
- - [certbot_nginx](./Linux/certbot_nginx.md)
|
||||||
|
- [MySQL](./MySQL/)
|
||||||
|
- - [all_foreign_keys_to_table_or_column](./MySQL/all_foreign_keys_to_table_or_column.md)
|
||||||
|
- - [identify_lock](./MySQL/identify_lock.md)
|
||||||
|
- - [users](./MySQL/users.md)
|
Loading…
Reference in New Issue