Compare commits

...

8 Commits

Author SHA1 Message Date
Dhaverd eb557b89a1 Обновить Readme.md 2025-06-18 09:45:37 +03:00
Dhaverd e4e199f180 Добавить Git/common.md 2025-06-18 09:44:54 +03:00
p.belezov 2d9bcfdaf0 MySQL users 2025-01-22 17:22:37 +08:00
p.belezov df16a13800 added git to readme 2025-01-20 13:06:24 +08:00
p.belezov 74aaa072aa added git 2025-01-20 13:05:12 +08:00
Dhaverd 1502f90c91 fixed readme 2025-01-19 21:33:09 +08:00
Dhaverd 7ac2b47822 certbot 2025-01-19 21:27:19 +08:00
p.belezov 80156574dd removed old link 2025-01-16 14:19:36 +08:00
6 changed files with 141 additions and 2 deletions

13
Git/common.md Normal file
View File

@ -0,0 +1,13 @@
# git common stuff
## change remote url
```
git remote set-url origin <new url>
```
## remove permission change from git diff
```
git config core.filemode false
```

7
Git/stash.md Normal file
View File

@ -0,0 +1,7 @@
# $git stash
## Stashing 1 file
```
git stash push [-m <message>] [--] [<pathspec>...]
```

13
Linux/certbot_nginx.md Normal file
View File

@ -0,0 +1,13 @@
# Certbot renew certificate
## touch nginx config
```
sudo certbot --nginx
```
## certificate only
```
sudo certbot certonly --nginx
```

View File

@ -1,5 +1,4 @@
# 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

101
MySQL/users.md Normal file
View File

@ -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';
```

View File

@ -4,6 +4,12 @@ This is a repository with useful snippets of various kinds of code
## Structure
- [Git](./src/branch/master/Git/)
- - [stash](./src/branch/master/Git/stash.md)
- - [common](./src/branch/master/Git/common.md)
- [Linux](./src/branch/master/Linux/)
- - [certbot_nginx](./src/branch/master/Linux/certbot_nginx.md)
- [MySQL](./src/branch/master/MySQL)
- - [all_foreign_keys_to_table_or_column](./src/branch/master/MySQL/all_foreign_keys_to_table_or_column.md)
- - [identify_lock](./src/branch/master/MySQL/identify_lock.md)
- - [identify_lock](./src/branch/master/MySQL/identify_lock.md)
- - [users](./src/branch/master/MySQL/users.md)