Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29d5656643 | ||
|
|
bc303c0eff | ||
|
|
192f67bdfe | ||
|
|
5c00bbfe41 | ||
|
|
c50f27d110 | ||
|
|
eb557b89a1 | ||
|
|
e4e199f180 | ||
|
|
2d9bcfdaf0 | ||
|
|
df16a13800 | ||
|
|
74aaa072aa | ||
|
|
1502f90c91 | ||
|
|
7ac2b47822 | ||
|
|
80156574dd |
|
|
@ -0,0 +1,13 @@
|
||||||
|
# git common stuff
|
||||||
|
|
||||||
|
## change remote url
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git remote set-url origin <new url>
|
||||||
|
```
|
||||||
|
|
||||||
|
## remove permission change from git diff
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git config core.filemode false
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
# $git stash
|
||||||
|
|
||||||
|
## Stashing 1 file
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git stash push [-m <message>] [--] [<pathspec>...]
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
# My Jujutsu aliases
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[aliases]
|
||||||
|
init = ["git", "init", "--colocate"]
|
||||||
|
cma = ["commit", "-m"]
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Certbot renew certificate
|
||||||
|
|
||||||
|
## touch nginx config
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo certbot --nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
## certificate only
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo certbot certonly --nginx
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Process interaction snippets
|
||||||
|
|
||||||
|
## Find process occupying port
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ss -lptn 'sport = :5173'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
|
||||||
|
LISTEN 0 511 [::1]:5173 [::]:* users:(("node",pid=29634,fd=32))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Kill process
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo kill -[signal] [PID]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo kill -9 29634
|
||||||
|
```
|
||||||
|
|
||||||
|
### Signals:
|
||||||
|
- **SIGTERM (Signal 15).** This signal asks for a process to terminate. The process can capture this signal, perform cleanup operations, and then exit. By default, the kill command sends SIGTERM if no other signal is specified.
|
||||||
|
|
||||||
|
- **SIGKILL (Signal 9).** It forcefully kills a process. The process cannot capture or ignore this signal, which results in an immediate termination. It should be used as a last resort when a process doesn’t respond to SIGTERM.
|
||||||
|
|
||||||
|
- **SIGINT (Signal 2).** This is typically sent when you press Ctrl + C in the terminal. It interrupts a process and is usually used to stop a process running in the foreground.
|
||||||
|
|
||||||
|
- **SIGHUP (Signal 1).** Sent to a process when its controlling terminal is closed and often used to reload configuration files.
|
||||||
|
|
||||||
|
- **SIGQUIT (Signal 3).** Causes a process to terminate and produce a core dump file for debugging.
|
||||||
|
|
||||||
|
- **SIGSTOP (Signal 19).** Pauses a process without killing it, similar to pressing Ctrl + Z in the terminal.
|
||||||
|
|
||||||
|
- **SIGCONT (Signal 18).** Continues a process that was stopped by SIGSTOP or Ctrl + Z.
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
# 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
|
||||||
|
|
||||||
```
|
```SQL
|
||||||
SELECT
|
SELECT
|
||||||
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
|
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
|
||||||
FROM
|
FROM
|
||||||
|
|
@ -15,7 +14,7 @@ WHERE
|
||||||
|
|
||||||
## By table column
|
## By table column
|
||||||
|
|
||||||
```
|
```SQL
|
||||||
SELECT
|
SELECT
|
||||||
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
|
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
|
||||||
FROM
|
FROM
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
## Method 1
|
## Method 1
|
||||||
|
|
||||||
```
|
```SQL
|
||||||
SHOW open tables WHERE In_use > 0;
|
SHOW open tables WHERE In_use > 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Method 2
|
## Method 2
|
||||||
|
|
||||||
```
|
```SQL
|
||||||
SELECT
|
SELECT
|
||||||
OBJECT_SCHEMA,
|
OBJECT_SCHEMA,
|
||||||
OBJECT_NAME,
|
OBJECT_NAME,
|
||||||
|
|
@ -24,6 +24,6 @@ GROUP BY
|
||||||
|
|
||||||
## Process list
|
## Process list
|
||||||
|
|
||||||
```
|
```SQL
|
||||||
SHOW PROCESSLIST;
|
SHOW PROCESSLIST;
|
||||||
```
|
```
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
# MySQL users actions
|
||||||
|
|
||||||
|
## Show users with hosts
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
SELECT User, Host FROM mysql.user;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check user privileges
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
SHOW GRANTS FOR 'someuser'@'somehost.somedomain';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create user
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
CREATE USER 'some_user'@'somehost.somedomain' IDENTIFIED BY 'some_password';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Delete user
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
DROP USER 'some_user'@'somehost.somedomain';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Granting privileges
|
||||||
|
|
||||||
|
### Grant all privileges
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'somehost.somedomain' WITH GRANT OPTION;
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant privilege on database 'some_db'
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
GRANT SELECT ON `some_db`.* TO 'some_user'@'somehost.somedomain';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant privilege on table 'some_db'.'some_table'
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
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'
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
GRANT SELECT (id, some_column), UPDATE (some_column) ON `some_db`.`some_table` TO 'some_user'@'somehost.somedomain';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grant with inheritance
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
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'
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
REVOKE SELECT ON `somedb`.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges from user
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
ALL PRIVILEGES ON *.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges to database 'somedb' from user
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
ALL PRIVILEGES ON `somedb`.* FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Revoke all privileges from user
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'someuser'@'somehost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Change password
|
||||||
|
|
||||||
|
```SQL
|
||||||
|
ALTER USER 'test_user'@'localhost' IDENTIFIED BY 'new_password';
|
||||||
|
```
|
||||||
11
Readme.md
11
Readme.md
|
|
@ -4,6 +4,15 @@ This is a repository with useful snippets of various kinds of code
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
|
- [Git](./src/branch/master/Git/)
|
||||||
|
- - [stash](./src/branch/master/Git/stash.md)
|
||||||
|
- - [common](./src/branch/master/Git/common.md)
|
||||||
|
- [Jujutsu](./src/branch/master/Jujutsu/)
|
||||||
|
- - [aliases](./src/branch/master/Jujutsu/aliases.md)
|
||||||
|
- [Linux](./src/branch/master/Linux/)
|
||||||
|
- - [certbot_nginx](./src/branch/master/Linux/certbot_nginx.md)
|
||||||
|
- - [processes](./src/branch/master/Linux/processes.md)
|
||||||
- [MySQL](./src/branch/master/MySQL)
|
- [MySQL](./src/branch/master/MySQL)
|
||||||
- - [all_foreign_keys_to_table_or_column](./src/branch/master/MySQL/all_foreign_keys_to_table_or_column.md)
|
- - [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)
|
||||||
Loading…
Reference in New Issue