15-09-2021
This commit is contained in:
@@ -4,9 +4,9 @@ https://github.com/kazhala/dotbare
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Installation
|
### Installation
|
||||||
|
|
||||||
##### Dépendances
|
#### Dépendances
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install fzf tree bat (ou highlight, coderay) delta (ou diff-so-fancy)
|
brew install fzf tree bat (ou highlight, coderay) delta (ou diff-so-fancy)
|
||||||
@@ -14,7 +14,7 @@ brew install fzf tree bat (ou highlight, coderay) delta (ou diff-so-fancy)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### zsh:
|
#### zsh:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# zinit
|
# zinit
|
||||||
@@ -36,7 +36,7 @@ puis source ~/.dotbare/dotbare.plugin.zsh dans les fichiers .zshrc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### bash:
|
#### bash:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ git clone https://github.com/kazhala/dotbare.git ~/.dotbare
|
$ git clone https://github.com/kazhala/dotbare.git ~/.dotbare
|
||||||
@@ -46,7 +46,7 @@ puis source ~/.dotbare/dotbare.plugin.bash dans les fichiers .bashrc ou .bash_pr
|
|||||||
|
|
||||||
#####
|
#####
|
||||||
|
|
||||||
##### Initialisation:
|
#### Initialisation:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# init dépôt git bare (dans $HOME/.cfg).
|
# init dépôt git bare (dans $HOME/.cfg).
|
||||||
@@ -56,9 +56,9 @@ $ dotbare finit
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Utilisation:
|
### Utilisation:
|
||||||
|
|
||||||
##### Ajouter les fichiers à suivre:
|
#### Ajouter les fichiers à suivre:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Fichiers
|
# Fichiers
|
||||||
@@ -76,7 +76,7 @@ $ dotbare add [DIRECTORY]
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### Commit changes and push to remote:
|
#### Commit changes and push to remote:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ dotbare commit -m "First commit"
|
$ dotbare commit -m "First commit"
|
||||||
@@ -86,7 +86,7 @@ $ dotbare push -u origin master
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### Alias:
|
#### Alias:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
alias dbpush='dotbare push -u mbv master'
|
alias dbpush='dotbare push -u mbv master'
|
||||||
@@ -97,7 +97,7 @@ alias dbback='dotbare fbackup'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### Préférences:
|
#### Préférences:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Default value
|
# Default value
|
||||||
@@ -124,7 +124,7 @@ export DOTBARE_DIFF_PAGER="delta --diff-so-fancy --line-numbers"
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fbackup:
|
#### fbackup:
|
||||||
|
|
||||||
D'après la variable DOTBARE_BACKUP
|
D'après la variable DOTBARE_BACKUP
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ $ dotbare fbackup -s
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fedit:
|
#### fedit:
|
||||||
|
|
||||||
- Select files/commits through fzf and edit selected files/commits in EDITOR.
|
- Select files/commits through fzf and edit selected files/commits in EDITOR.
|
||||||
- Default: list all tracked dotfiles and edit the selected files.
|
- Default: list all tracked dotfiles and edit the selected files.
|
||||||
@@ -163,7 +163,7 @@ $ dotbare fedit
|
|||||||
# -c: affiche les commits
|
# -c: affiche les commits
|
||||||
```
|
```
|
||||||
|
|
||||||
##### fgrep:
|
#### fgrep:
|
||||||
|
|
||||||
- Grep words within tracked files and select to edit matches.
|
- Grep words within tracked files and select to edit matches.
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ $ dotbare fgrep
|
|||||||
# -f, --full include all column during search, as if using '--col 1'.
|
# -f, --full include all column during search, as if using '--col 1'.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### flog:
|
#### flog:
|
||||||
|
|
||||||
- Interactive log viewer with action menu.
|
- Interactive log viewer with action menu.
|
||||||
- Action menu contains options including revert|reset|edit|checkout|exit.
|
- Action menu contains options including revert|reset|edit|checkout|exit.
|
||||||
@@ -190,7 +190,7 @@ $ dotbare flog
|
|||||||
# -y, --yes acknowledge all actions that will be taken and skip confirmation.
|
# -y, --yes acknowledge all actions that will be taken and skip confirmation.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### freset
|
#### freset:
|
||||||
|
|
||||||
- Reset(unstage) the selected staged files. (Default)
|
- Reset(unstage) the selected staged files. (Default)
|
||||||
- Reset the HEAD to certain commits by using -c flag.
|
- Reset the HEAD to certain commits by using -c flag.
|
||||||
@@ -206,7 +206,7 @@ $ dotbare freset
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fcheckout
|
#### fcheckout:
|
||||||
|
|
||||||
- Select files/commit/branch through fzf and checkout the selected objects.
|
- Select files/commit/branch through fzf and checkout the selected objects.
|
||||||
- Files: checkout the version in HEAD or in a specific commit (reset files content back to the selected commit).
|
- Files: checkout the version in HEAD or in a specific commit (reset files content back to the selected commit).
|
||||||
@@ -226,17 +226,17 @@ $ dotbare fcheckout
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fstash
|
#### fstash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fstat
|
#### fstat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### funtrack
|
#### funtrack
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### fupgrade
|
#### fupgrade
|
||||||
|
|
||||||
|
|||||||
@@ -364,5 +364,45 @@ ESC - H: Affiche le MAN d'une commande
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### bookmarks:
|
||||||
|
|
||||||
|
[how-to-use-bookmarks-in-bash-zsh](https://threkk.medium.com/how-to-use-bookmarks-in-bash-zsh-6b8074e40774)
|
||||||
|
|
||||||
|
Ajouter au .zshrc
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if [ -d "$HOME/.bookmarks" ]; then
|
||||||
|
export CDPATH=".:$HOME/.bookmarks:/"
|
||||||
|
alias goto="cd -P"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Créer le dossier .bookmarks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir ~/.bookmarks
|
||||||
|
```
|
||||||
|
|
||||||
|
Ajouter les bookmarks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/.bookmarks
|
||||||
|
$ ln -s /Users/bruno/Documents/MySQL @MySQL_backup
|
||||||
|
|
||||||
|
~/.bookmarks
|
||||||
|
$ ln -s $(brew --prefix)/var/mysql @MySQL_databases
|
||||||
|
```
|
||||||
|
|
||||||
|
Utilisation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ goto @<Tab>
|
||||||
|
@MySQL_backup@ @MySQL_databases@ @kymsu@ @kymsu_git@ @scripts_bash@
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour [bash](https://twitter.com/mattn_jp/status/1434192554036137995)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
http://grml.org/zsh/zsh-lovers.html
|
http://grml.org/zsh/zsh-lovers.html
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
# Fix the 2002 MySQL Socket error (OSX)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ sudo mkdir /var/mysql
|
|
||||||
|
|
||||||
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
|
|
||||||
```
|
|
||||||
|
|
||||||
158
docs/MySQL/bases.md
Normal file
158
docs/MySQL/bases.md
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
# Bases
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Voir toutes les bases:
|
||||||
|
|
||||||
|
`mysql> SHOW DATABASES;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW DATABASES;
|
||||||
|
+--------------------+
|
||||||
|
| Database |
|
||||||
|
+--------------------+
|
||||||
|
| information_schema |
|
||||||
|
| mysql |
|
||||||
|
| performance_schema |
|
||||||
|
| sys |
|
||||||
|
| wordpress |
|
||||||
|
+--------------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Utiliser une base existante:
|
||||||
|
|
||||||
|
`mysql> USE database;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> USE wordpress;
|
||||||
|
Reading table information for completion of table and column names
|
||||||
|
You can turn off this feature to get a quicker startup with -A
|
||||||
|
|
||||||
|
Database changed
|
||||||
|
MariaDB [wordpress]>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Créer une base de donnée:
|
||||||
|
|
||||||
|
`mysql> CREATE DATABASE database;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> CREATE DATABASE bdd;
|
||||||
|
Query OK, 1 row affected (0.001 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
et donner les privilèges à un utilisateur (existant) sur cette base:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> GRANT ALL ON bdd.* TO 'theuser'@'localhost';
|
||||||
|
Query OK, 0 rows affected (0.021 sec)
|
||||||
|
|
||||||
|
MariaDB [(none)]> FLUSH PRIVILEGES
|
||||||
|
```
|
||||||
|
|
||||||
|
ou à un utilisateur qui n'existe pas encore:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> GRANT ALL ON bdd.* TO 'matrix'@'localhost' IDENTIFIED BY 'password';
|
||||||
|
Query OK, 0 rows affected (0.030 sec)
|
||||||
|
|
||||||
|
MariaDB [(none)]> FLUSH PRIVILEGES
|
||||||
|
```
|
||||||
|
|
||||||
|
L'utilisateur 'matrix' sera crée.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`mysql> CREATE DATABASE IF NOT EXISTS database;`
|
||||||
|
|
||||||
|
Avec `IF NOT EXISTS`, la base est créée uniquement si il n'y a pas de conflit de nom. Sans, MySQL envoie une erreur.
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS bdd;
|
||||||
|
Query OK, 1 row affected (0.003 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`CHARACTER SET` `COLLATE`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
Query OK, 1 row affected (0.005 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Supprimer une base:
|
||||||
|
|
||||||
|
`mysql> DROP DATABASE database;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> DROP DATABASE bdd;
|
||||||
|
Query OK, 0 rows affected (0.074 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
Ajouter `IF EXISTS` évite le message d'erreur si la base n'existe pas:
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> DROP DATABASE IF EXISTS zenphoto;
|
||||||
|
Query OK, 0 rows affected, 1 warning (0.000 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> DROP DATABASE zenphoto;
|
||||||
|
ERROR 1008 (HY000): Can't drop database 'zenphoto'; database doesn't exist
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Bases dans macOS:
|
||||||
|
|
||||||
|
Les bases se trouvent dans: `$(brew --prefix)/var/mysql`
|
||||||
|
|
||||||
|
**mac intel:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bruno@SilverBook: /usr/local/var/mysql $ l
|
||||||
|
total 245920
|
||||||
|
-rw-rw---- 1 bruno admin 6519 15 oct 17:48 SilverBook.local.err
|
||||||
|
-rw-rw---- 1 bruno admin 5 15 oct 17:48 SilverBook.local.pid
|
||||||
|
-rw-rw---- 1 bruno admin 24576 15 oct 17:46 aria_log.00000001
|
||||||
|
-rw-rw---- 1 bruno admin 52 15 oct 17:46 aria_log_control
|
||||||
|
-rw-r----- 1 bruno admin 976 15 oct 17:46 ib_buffer_pool
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 15 oct 17:48 ib_logfile0
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 6 aoû 20:18 ib_logfile1
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 15 oct 17:46 ibdata1
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 15 oct 17:48 ibtmp1
|
||||||
|
-rw-rw---- 1 bruno admin 0 6 aoû 20:18 multi-master.info
|
||||||
|
drwx------ 90 bruno admin 2880 6 aoû 20:18 mysql
|
||||||
|
drwx------ 3 bruno admin 96 6 aoû 20:18 performance_schema
|
||||||
|
-rw-rw---- 1 bruno admin 3047 11 aoû 22:49 silverbook-1.home.err
|
||||||
|
-rw-rw---- 1 bruno admin 30926 15 oct 17:46 silverbook.home.err
|
||||||
|
```
|
||||||
|
|
||||||
|
**mac M1:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ cd /opt/homebrew/var/mysql
|
||||||
|
total 123324
|
||||||
|
-rw-rw---- 1 bruno admin 7308 sep 2 16:19 AirBook.err
|
||||||
|
-rw-rw---- 1 bruno admin 5 aoû 11 23:09 airbook.pid
|
||||||
|
-rw-rw---- 1 bruno admin 417792 sep 3 18:18 aria_log.00000001
|
||||||
|
-rw-rw---- 1 bruno admin 52 aoû 11 22:49 aria_log_control
|
||||||
|
-rw-rw---- 1 bruno admin 16384 sep 3 18:18 ddl_recovery.log
|
||||||
|
-rw-r----- 1 bruno admin 946 aoû 11 22:49 ib_buffer_pool
|
||||||
|
-rw-rw---- 1 bruno admin 100663296 sep 3 18:18 ib_logfile0
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 aoû 11 22:49 ibdata1
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 aoû 11 23:09 ibtmp1
|
||||||
|
-rw-rw---- 1 bruno admin 0 jul 29 09:44 multi-master.info
|
||||||
|
drwx------ 90 bruno admin 2880 sep 3 18:18 mysql
|
||||||
|
drwx------ 3 bruno admin 96 jul 29 09:43 performance_schema
|
||||||
|
drwx------ 109 bruno admin 3488 sep 3 18:18 sys
|
||||||
|
drwx------ 27 bruno admin 864 sep 3 18:18 wordpress
|
||||||
|
```
|
||||||
|
|
||||||
78
docs/MySQL/connexion.md
Normal file
78
docs/MySQL/connexion.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Connexion à la base:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Se connecter à MySQL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysql -u root -p
|
||||||
|
Enter password:
|
||||||
|
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||||
|
Your MariaDB connection id is 18
|
||||||
|
Server version: 10.3.11-MariaDB Homebrew
|
||||||
|
|
||||||
|
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||||
|
|
||||||
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||||
|
|
||||||
|
MariaDB [(none)]>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Se connecter directement à une base:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysql -u root -p wordpress
|
||||||
|
Enter password:
|
||||||
|
Reading table information for completion of table and column names
|
||||||
|
You can turn off this feature to get a quicker startup with -A
|
||||||
|
|
||||||
|
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
||||||
|
Your MariaDB connection id is 139
|
||||||
|
Server version: 10.6.4-MariaDB Homebrew
|
||||||
|
|
||||||
|
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
||||||
|
|
||||||
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
||||||
|
|
||||||
|
MariaDB [wordpress]>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`$ mysql -u root -pwordpress`: se connecter directement à MySQL avec le mot de passe 'wordpress'.
|
||||||
|
|
||||||
|
`$ mysql -u root -p wordpress`: se connecter à la base wordpress. Le mot de passe est demandé.
|
||||||
|
|
||||||
|
`$ mysql -u root -ppassword wordpress`: se connecter directement à la base wordpress avec le mot de passe 'password'.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Configuration:
|
||||||
|
|
||||||
|
#### my.cnf
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bruno@SilverBook: /usr/local/etc $ ls -la
|
||||||
|
total 160
|
||||||
|
-rw-r--r-- 1 bruno admin 212 4 sep 16:53 my.cnf
|
||||||
|
drwxr-xr-x 3 bruno admin 96 16 aoû 10:43 my.cnf.d
|
||||||
|
-rw-r--r-- 1 bruno admin 113 4 sep 16:53 my.cnf.default
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bruno@SilverBook: /usr/local/etc/my.cnf.d $ l
|
||||||
|
total 0
|
||||||
|
-rw-r--r-- 1 bruno admin 0 16 aoû 10:43 wont_prune.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Quitter MySQL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
MariaDB [wordpress4]> exit
|
||||||
|
Bye
|
||||||
|
```
|
||||||
|
|
||||||
14
docs/MySQL/host.md
Normal file
14
docs/MySQL/host.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Host
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Host est la machine à partir de laquelle l'utilisateur se connecte se connecte à la base.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| host | |
|
||||||
|
| ---------------- | ------------------------------------------------------------ |
|
||||||
|
| '%' | - depuis n'importe quel host (remote & local) (wildcard)<br />- n'inclue pas 'localhost' qui suppose un connexion par socket unix au lieu du standard TCP/IP |
|
||||||
|
| 'localhost' | - uniquement des connections locales |
|
||||||
|
| '198.51.100.177' | - depuis le host dont l'IP est '198.51.100.177' |
|
||||||
|
|
||||||
@@ -2,84 +2,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Install MariaDB avec Homebrew:
|
1. [Installation (Homebrew)](install.md)
|
||||||
|
2. [Connexion](connexion.md)
|
||||||
|
3. [Type de bases](type_bases.md)
|
||||||
|
4. [Host](host.md)
|
||||||
|
5. [Bases (requêtes)](bases.md)
|
||||||
|
6. [Utilisateurs (requêtes)](users.md)
|
||||||
|
7. [Privilèges (requêtes)](privileges.md)
|
||||||
|
8. [Tables (requêtes)](tables.md)
|
||||||
|
9. [select](select.md)
|
||||||
|
10. [Réparer](repair.md)
|
||||||
|
11. [Backup](Backup.md)
|
||||||
|
12. [mysqlcheck](mysqlcheck.md)
|
||||||
|
13. [Passwords](password.md)
|
||||||
|
14. [Trucs](trucs.md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
Voir le n° de version:
|
||||||
bruno@SilverBook: ~ $ sudo find / -name mysql
|
|
||||||
Password:
|
```mariadb
|
||||||
/usr/local/bin/mysql
|
MariaDB [(none)]> SELECT VERSION(), CURRENT_DATE;
|
||||||
/usr/local/include/mysql
|
+----------------+--------------+
|
||||||
/usr/local/etc/init.d/mysql
|
| VERSION() | CURRENT_DATE |
|
||||||
/usr/local/etc/logrotate.d/mysql
|
+----------------+--------------+
|
||||||
/usr/local/var/mysql
|
| 10.6.4-MariaDB | 2021-09-04 |
|
||||||
/usr/local/var/mysql/mysql
|
+----------------+--------------+
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/bin/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/server/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/init.d/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/logrotate.d/mysql
|
|
||||||
/usr/local/Cellar/mariadb/10.4.6_1/share/mysql
|
|
||||||
/usr/local/share/mysql
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### my.cnf
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bruno@SilverBook: /usr/local/etc $ ls -la
|
|
||||||
total 160
|
|
||||||
-rw-r--r-- 1 bruno admin 212 4 sep 16:53 my.cnf
|
|
||||||
drwxr-xr-x 3 bruno admin 96 16 aoû 10:43 my.cnf.d
|
|
||||||
-rw-r--r-- 1 bruno admin 113 4 sep 16:53 my.cnf.default
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bruno@SilverBook: /usr/local/etc/my.cnf.d $ l
|
|
||||||
total 0
|
|
||||||
-rw-r--r-- 1 bruno admin 0 16 aoû 10:43 wont_prune.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Bases
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bruno@SilverBook: /usr/local/var/mysql $ l
|
|
||||||
total 245920
|
|
||||||
-rw-rw---- 1 bruno admin 6519 15 oct 17:48 SilverBook.local.err
|
|
||||||
-rw-rw---- 1 bruno admin 5 15 oct 17:48 SilverBook.local.pid
|
|
||||||
-rw-rw---- 1 bruno admin 24576 15 oct 17:46 aria_log.00000001
|
|
||||||
-rw-rw---- 1 bruno admin 52 15 oct 17:46 aria_log_control
|
|
||||||
-rw-r----- 1 bruno admin 976 15 oct 17:46 ib_buffer_pool
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 15 oct 17:48 ib_logfile0
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 6 aoû 20:18 ib_logfile1
|
|
||||||
-rw-rw---- 1 bruno admin 12582912 15 oct 17:46 ibdata1
|
|
||||||
-rw-rw---- 1 bruno admin 12582912 15 oct 17:48 ibtmp1
|
|
||||||
-rw-rw---- 1 bruno admin 0 6 aoû 20:18 multi-master.info
|
|
||||||
drwx------ 90 bruno admin 2880 6 aoû 20:18 mysql
|
|
||||||
drwx------ 3 bruno admin 96 6 aoû 20:18 performance_schema
|
|
||||||
-rw-rw---- 1 bruno admin 3047 11 aoû 22:49 silverbook-1.home.err
|
|
||||||
-rw-rw---- 1 bruno admin 30926 15 oct 17:46 silverbook.home.err
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Reset Expired root Password for MySQL 5.7 on Mac OS X](Expired-root-Password.md)
|
|
||||||
|
|
||||||
[mysqlcheck](mysqlcheck.md)
|
|
||||||
|
|
||||||
[backup](Backup.md)
|
|
||||||
|
|
||||||
[Socket error](Socket-error.md)
|
|
||||||
|
|
||||||
[Commandes diverses](diverses.md)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Liens:
|
### Liens:
|
||||||
|
|
||||||
[:fa-link: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/](https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/)
|
[:fa-link: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/](https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/)
|
||||||
|
|||||||
55
docs/MySQL/install.md
Normal file
55
docs/MySQL/install.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Install MariaDB avec Homebrew:
|
||||||
|
|
||||||
|
#### Installation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ brew install mariadb
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Démarrer le serveur:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ brew services start mariadb
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Changer le mot-de-passe MySQL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo /usr/local/bin/mysql_secure_installation
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Arrêter le serveur:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ brew services stop mariadb
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Fichiers installés:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bruno@SilverBook: ~ $ sudo find / -name mysql
|
||||||
|
Password:
|
||||||
|
/usr/local/bin/mysql
|
||||||
|
/usr/local/include/mysql
|
||||||
|
/usr/local/etc/init.d/mysql
|
||||||
|
/usr/local/etc/logrotate.d/mysql
|
||||||
|
/usr/local/var/mysql
|
||||||
|
/usr/local/var/mysql/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/bin/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/server/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/init.d/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/logrotate.d/mysql
|
||||||
|
/usr/local/Cellar/mariadb/10.4.6_1/share/mysql
|
||||||
|
/usr/local/share/mysql
|
||||||
|
```
|
||||||
|
|
||||||
150
docs/MySQL/privileges.md
Normal file
150
docs/MySQL/privileges.md
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
# Privileges:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Le contrôle d'accès de MySQL se fait en deux étapes :
|
||||||
|
|
||||||
|
- Etape 1 : Le serveur vérifie que vous êtes autorisé à vous connecter.
|
||||||
|
- Etape 2 : En supposant que vous pouvez vous connecter, le serveur vérifie chaque requête que vous soumettez, pour vérifier si vous avez les droits suffisants pour l'exécuter. Par exemple, si vous sélectionnez des droits dans une table, ou effacez une table, le serveur s'assure que vous avez les droits de SELECT pour cette table, ou les droits de DROP, respectivement.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Les commandes les plus courantes:
|
||||||
|
|
||||||
|
- **ALL PRIVILEGES** – Donne à l'utilisateur de MySQL un total accès à une base de données désignée (ou un accès global à l'ensemble du système si aucune base de données n'est sélectionnée)
|
||||||
|
- **CREATE** – Permet aux utilisateurs de créer des bases de données/tableaux
|
||||||
|
- **ALTER** –
|
||||||
|
|
||||||
|
- **SELECT** – Permet aux utilisateurs de récupérer des données
|
||||||
|
|
||||||
|
- **INSERT** – Permet aux utilisateurs d’ajouter de nouvelles entrées dans les tableaux
|
||||||
|
|
||||||
|
- **UPDATE** – Permet aux utilisateurs de modifier les entrées existantes dans les tableaux
|
||||||
|
|
||||||
|
- **DELETE** – Permet aux utilisateurs de supprimer les entrées de la tableau
|
||||||
|
|
||||||
|
- **DROP** – Permet aux utilisateurs de supprimer des bases de données/tableaux entiers
|
||||||
|
- **GRANT OPTION** – Permet d'accorder ou de supprimer les privilèges des autres utilisateurs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Liste des commandes:
|
||||||
|
|
||||||
|
```
|
||||||
|
GRANT
|
||||||
|
SELECT, INSERT, DROP, UPDATE, DELETE, CREATE, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR
|
||||||
|
ON *.* TO
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Voir les droits de l'utilisateur courant:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW GRANTS;
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| Grants for root@localhost |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*1111111111111111111111111111111111' OR unix_socket WITH GRANT OPTION |
|
||||||
|
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Voir les droits d'un utilisateur 'mysqlbackupuser' sur un host:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW GRANTS FOR 'mysqlbackupuser'@'localhost';
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| Grants for mysqlbackupuser@localhost |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| GRANT SELECT, LOCK TABLES ON *.* TO `mysqlbackupuser`@`localhost` IDENTIFIED BY PASSWORD '*22222222222222222222222222222222222222222' |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
1 row in set (0.000 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
Si le host n'est pas précisé, il s'agit de **'%'**
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW GRANTS FOR 'mysqlbackupuser';
|
||||||
|
ERROR 1141 (42000): There is no such grant defined for user 'mysqlbackupuser' on host '%'
|
||||||
|
```
|
||||||
|
|
||||||
|
Les droits peuvent être différents d'une base à l'autre:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW GRANTS FOR 'the_user'@'localhost';
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| Grants for the_user@localhost |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `the_user`@`localhost` IDENTIFIED BY PASSWORD '*201716EF6717C367868F777B9C6E17796F19F379' |
|
||||||
|
|
|
||||||
|
| GRANT ALL PRIVILEGES ON `bdd`.* TO `the_user`@`localhost` |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Donner tous les droits à l'utilisateur:
|
||||||
|
|
||||||
|
-sur une base:
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mydatabase.* TO the_user@localhost;
|
||||||
|
Query OK, 0 rows affected (0.029 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
-sur le tout le serveur:
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO the_user@localhost;
|
||||||
|
Query OK, 0 rows affected (0.025 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour que les changements prennent effets:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Révocation de privilèges:
|
||||||
|
|
||||||
|
`mysql> REVOKE ALL PRIVILEGES;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> REVOKE ALL PRIVILEGES ON *.* FROM the_user@localhost;
|
||||||
|
Query OK, 0 rows affected (0.023 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
`mysql> REVOKE <PRIVILEGES>;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> SHOW GRANTS FOR 'the_user'@'localhost';
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| Grants for the_user@localhost |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| GRANT ALL PRIVILEGES ON *.* TO `the_user`@`localhost` IDENTIFIED BY PASSWORD '*201716EF6717C367868F777B9C6E17796F19F379' |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
On supprime les privilèges DROP et SHUTDOWN:
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> REVOKE DROP, SHUTDOWN ON *.* FROM the_user@localhost;
|
||||||
|
Query OK, 0 rows affected (0.022 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [(none)]> SHOW GRANTS FOR 'the_user'@'localhost';
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| Grants for the_user@localhost |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, RELOAD, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `the_user`@`localhost` IDENTIFIED BY PASSWORD '*201716EF6717C367868F777B9C6E17796F19F379' |
|
||||||
|
+----------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
179
docs/MySQL/repair.md
Normal file
179
docs/MySQL/repair.md
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
# Réparer des tables :
|
||||||
|
|
||||||
|
[MySQL Server logs](https://dev.mysql.com/doc/refman/5.7/en/server-logs.html)
|
||||||
|
|
||||||
|
La 1ere chose à faire en cas de problèmes est de consulter les fichiers logs. Ceux-çi sont généralement avec les tables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#osx (Homebrew):
|
||||||
|
|
||||||
|
$ cd /usr/local/var/mysql
|
||||||
|
total 388560
|
||||||
|
drwxr-xr-x 32 bruno admin 1024 28 nov 16:53 .
|
||||||
|
drwxrwxr-x 13 bruno admin 416 16 fév 2018 ..
|
||||||
|
-rw-rw---- 1 bruno admin 16384 28 nov 08:08 aria_log.00000001
|
||||||
|
-rw-rw---- 1 bruno admin 52 28 nov 08:08 aria_log_control
|
||||||
|
drwx------ 48 bruno admin 1536 1 déc 17:05 funnymac
|
||||||
|
drwx------ 53 bruno admin 1696 1 déc 17:05 ghost_prod
|
||||||
|
-rw-r----- 1 bruno admin 15114 28 nov 08:08 ib_buffer_pool
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 3 déc 07:19 ib_logfile0
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 24 oct 12:51 ib_logfile1
|
||||||
|
-rw-rw---- 1 bruno admin 79691776 3 déc 07:19 ibdata1
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 28 nov 16:53 ibtmp1
|
||||||
|
drwx------ 9 bruno admin 288 1 déc 17:05 mgpt
|
||||||
|
-rw-rw---- 1 bruno admin 0 24 jul 2017 multi-master.info
|
||||||
|
drwx------ 89 bruno admin 2848 1 déc 17:05 mysql
|
||||||
|
drwx------ 3 bruno admin 96 24 jul 2017 performance_schema
|
||||||
|
drwx------ 41 bruno admin 1312 1 déc 17:05 phpmyadmi
|
||||||
|
-rw-rw---- 1 bruno admin 1271878 3 déc 07:19 silverbook.home.err
|
||||||
|
-rw-rw---- 1 bruno admin 5 28 nov 16:53 silverbook.home.pid
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<u>Pour réparer, 2 solutions:</u>
|
||||||
|
|
||||||
|
**1) REPAIR TABLE:**
|
||||||
|
|
||||||
|
- ne nécessite pas l’arrêt de MySQL
|
||||||
|
- uniquement base MyISAM
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
MariaDB [zenphoto]> REPAIR TABLE _tags;
|
||||||
|
+----------------+--------+----------+---------------------------------------------------------+
|
||||||
|
| Table | Op | Msg_type | Msg_text |
|
||||||
|
+----------------+--------+----------+---------------------------------------------------------+
|
||||||
|
| zenphoto._tags | repair | note | The storage engine for the table doesn't support repair |
|
||||||
|
+----------------+--------+----------+---------------------------------------------------------+
|
||||||
|
|
||||||
|
1 row in set (0.006 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
Si l’erreur persiste, **vider le cache** (Flush all cache)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**2) mysqlcheck -r:**
|
||||||
|
|
||||||
|
- nécessite un arrêt du service MySQL
|
||||||
|
|
||||||
|
- uniquement base MyISAM
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[MyISAM](https://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysqlcheck -u root -ppassword -r zenphoto .comments
|
||||||
|
|
||||||
|
zenphoto..comments OK
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[InnoDB](https://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysqlcheck -u root -ppassword -r zenphoto _tags
|
||||||
|
|
||||||
|
zenphoto._tags
|
||||||
|
|
||||||
|
note : The storage engine for the table doesn't support repair
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour les tables InnoDB, il faut [forcer la récupération](https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html):
|
||||||
|
|
||||||
|
1) Arrêter **mysqld**:
|
||||||
|
|
||||||
|
2) Sauvegarder **mysql**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#Linux
|
||||||
|
/var/lib/mysql/
|
||||||
|
|
||||||
|
#osx (Homebrew)
|
||||||
|
/usr/local/var/mysql/
|
||||||
|
```
|
||||||
|
|
||||||
|
3) Ajouter au fichier de configuration MySQL my.cnf:
|
||||||
|
|
||||||
|
```
|
||||||
|
#osx (Homebrew): /usr/local/etc/my.cnf
|
||||||
|
|
||||||
|
[mysqld]
|
||||||
|
innodb_force_recovery = 4
|
||||||
|
```
|
||||||
|
|
||||||
|
4) Redémarrer **mysqld**:
|
||||||
|
|
||||||
|
5a) Faire un dump des tables de la base avec **SELECT ... INTO OUTFILE**:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [zenphoto]> SELECT * FROM _tags INTO OUTFILE '/tmp/corrupted.txt';
|
||||||
|
Query OK, 170 rows affected (0.011 sec)
|
||||||
|
|
||||||
|
# Pour exporter au format csv:
|
||||||
|
MariaDB [zenphoto]> SELECT * FROM _tags INTO OUTFILE '/tmp/corrupted.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
|
||||||
|
Query OK, 170 rows affected (0.006 sec)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
5b) Faire. un dump de toutes les tables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysqldump -A -u root -ppassword > '/tmp/dump.sql';
|
||||||
|
```
|
||||||
|
|
||||||
|
6) Parfois cela peut suffire. Sinon,
|
||||||
|
|
||||||
|
7) Supprimer les tables / bases corrompues (DROP ...)
|
||||||
|
|
||||||
|
8) Arrêter **mysqld**:
|
||||||
|
|
||||||
|
9) Supprimer les ib*:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#Linux
|
||||||
|
/var/lib/mysql/ib*
|
||||||
|
|
||||||
|
#osx (Homebrew)
|
||||||
|
/usr/local/var/mysql/ib*
|
||||||
|
```
|
||||||
|
|
||||||
|
10) Quitter le mode force recovery:
|
||||||
|
|
||||||
|
```
|
||||||
|
[mysqld]
|
||||||
|
#innodb_force_recovery = 0
|
||||||
|
```
|
||||||
|
|
||||||
|
11) Redémarrer **mysqld**:
|
||||||
|
|
||||||
|
12) Restaurer les bases:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysql -u root -ppassword < dump.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
https://www.nixpal.com/mysql-innodb-corruption-repair-guide/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Vérifier et réparer:
|
||||||
|
|
||||||
|
Vérifier toutes les bases et réparer les tables corrompues:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysqlcheck -u root -p -A --auto-repair
|
||||||
|
|
||||||
|
Enter password:
|
||||||
|
|
||||||
|
funnymac.download OK
|
||||||
|
funnymac.downloads OK
|
||||||
|
…/…
|
||||||
|
```
|
||||||
|
|
||||||
320
docs/MySQL/select.md
Normal file
320
docs/MySQL/select.md
Normal file
@@ -0,0 +1,320 @@
|
|||||||
|
# select
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
La commande SELECT est utilisée pour récupérer des informations à partir d'une table.
|
||||||
|
|
||||||
|
La forme usuelle est : `SELECT colonne FROM table WHERE condition;`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Sélectionner toutes les colonnes d'une table:
|
||||||
|
|
||||||
|
`SELECT * FROM table;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal;
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
|
||||||
|
| Slim | Benny | serpent | f | 1996-03-30 | NULL |
|
||||||
|
| Chirpy | Gwen | oiseau | m | 1996-03-10 | NULL |
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
| Bowser | Diane | chien | m | 1998-08-31 | 1995-07-29 |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
5 rows in set (0.001 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Sélectionner certaines colonnes d'une table:
|
||||||
|
|
||||||
|
`SELECT col1, col4 FROM table;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom,sexe FROM animal;
|
||||||
|
+----------+------+
|
||||||
|
| nom | sexe |
|
||||||
|
+----------+------+
|
||||||
|
| Puffball | f |
|
||||||
|
| Slim | f |
|
||||||
|
| Chirpy | m |
|
||||||
|
| Fluffy | m |
|
||||||
|
| Bowser | m |
|
||||||
|
+----------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Sélectionner certaines lignes:
|
||||||
|
|
||||||
|
`SELECT col1, col4 FROM table WHERE col5="x";`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom,sexe FROM animal WHERE sexe="m";
|
||||||
|
+--------+------+
|
||||||
|
| nom | sexe |
|
||||||
|
+--------+------+
|
||||||
|
| Chirpy | m |
|
||||||
|
| Fluffy | m |
|
||||||
|
| Bowser | m |
|
||||||
|
+--------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
Conditions WHERE:
|
||||||
|
|
||||||
|
- **=** : `WHERE sexe ="m"`
|
||||||
|
- **>=** ; **>** : `WHERE naissance >= "1998-1-1"`
|
||||||
|
- **<=** ; **<** : `WHERE naissance < "2000-1-1"`
|
||||||
|
- **AND** : `WHERE naissance >= "1998-1-1" AND naissance < "2000-1-1"`
|
||||||
|
- **OR** : `WHERE naissance >= "2000-1-1" OR naissance < "1998-1-1"`
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Afficher un résultat unique:
|
||||||
|
|
||||||
|
`SELECT DISTINCT col1 FROM table;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT DISTINCT sexe FROM animal;
|
||||||
|
+------+
|
||||||
|
| sexe |
|
||||||
|
+------+
|
||||||
|
| f |
|
||||||
|
| m |
|
||||||
|
+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Trier les résultats:
|
||||||
|
|
||||||
|
`SELECT col1, col2 FROM table ORDER BY col2;`
|
||||||
|
|
||||||
|
`SELECT col1, col2 FROM table ORDER BY col2 DESC;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom, naissance FROM animal ORDER BY naissance DESC;
|
||||||
|
+----------+------------+
|
||||||
|
| nom | naissance |
|
||||||
|
+----------+------------+
|
||||||
|
| Puffball | 1999-03-30 |
|
||||||
|
| Slim | 1996-03-30 |
|
||||||
|
| Chirpy | 1996-03-10 |
|
||||||
|
| Bowser | 1989-08-31 |
|
||||||
|
| Fluffy | 1984-11-10 |
|
||||||
|
+----------+------------+
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! Tri sur plusieurs colonnes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Calcul sur les dates:
|
||||||
|
|
||||||
|
Alias: `AS`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom, naissance, CURRENT_DATE,(YEAR(CURRENT_DATE)-YEAR(naissance)) - (RIGHT(CURRENT_DATE,5)<RIGHT(naissance,5)) AS age FROM animal ORDER BY nom;
|
||||||
|
+----------+------------+--------------+------+
|
||||||
|
| nom | naissance | CURRENT_DATE | age |
|
||||||
|
+----------+------------+--------------+------+
|
||||||
|
| Bowser | 1989-08-31 | 2021-09-04 | 32 |
|
||||||
|
| Chirpy | 1996-03-10 | 2021-09-04 | 25 |
|
||||||
|
| Fluffy | 1984-11-10 | 2021-09-04 | 36 |
|
||||||
|
| Puffball | 1999-03-30 | 2021-09-04 | 22 |
|
||||||
|
| Slim | 1996-03-30 | 2021-09-04 | 25 |
|
||||||
|
+----------+------------+--------------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom, naissance, MONTH(naissance) AS 'mois de naissance' FROM animal;
|
||||||
|
+----------+------------+-------------------+
|
||||||
|
| nom | naissance | mois de naissance |
|
||||||
|
+----------+------------+-------------------+
|
||||||
|
| Puffball | 1999-03-30 | 3 |
|
||||||
|
| Slim | 1996-03-30 | 3 |
|
||||||
|
| Chirpy | 1996-03-10 | 3 |
|
||||||
|
| Fluffy | 1984-11-10 | 11 |
|
||||||
|
| Bowser | 1989-08-31 | 8 |
|
||||||
|
+----------+------------+-------------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Valeur NULL:
|
||||||
|
|
||||||
|
Conceptuellement, NULL représente une valeur qui manque, ou une valeur inconnue. Utilisez les opérateurs IS NULL et IS NOT NULL.
|
||||||
|
|
||||||
|
Avec MySQL, 0 et NULL représentent le booléen faux, et tout le reste représente le booléen vrai. La valeur par défaut du booléen vrai issue d'une comparaison est 1.
|
||||||
|
|
||||||
|
Lorsque vous utilisez la clause ORDER BY, les valeurs NULL sont toujours triées en premier, même si vous utilisez l'attribut DESC.
|
||||||
|
|
||||||
|
Chercher les animaux morts:
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT nom, naissance, mort FROM animal WHERE mort IS NOT NULL;
|
||||||
|
+--------+------------+------------+
|
||||||
|
| nom | naissance | mort |
|
||||||
|
+--------+------------+------------+
|
||||||
|
| Bowser | 1989-08-31 | 1995-07-29 |
|
||||||
|
+--------+------------+------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Recherche de modèles:
|
||||||
|
|
||||||
|
`LIKE '_a'`: _ remplace n'importe quel caractère
|
||||||
|
|
||||||
|
`LIKE '___'`: trouve les noms de 3 caractères
|
||||||
|
|
||||||
|
`LIKE '%y'`: se termine par 'y'
|
||||||
|
|
||||||
|
`LIKE 'f%'`: commence par 'f'
|
||||||
|
|
||||||
|
`LIKE '%b%'`: contenant un 'b'
|
||||||
|
|
||||||
|
`NOT LIKE '%y'`: ne se termine pas par 'y'
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom LIKE "%y";
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| Chirpy | Gwen | oiseau | m | 1996-03-10 | NULL |
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom LIKE "f%";
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom LIKE "%b%";
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
|
||||||
|
| Bowser | Diane | chien | m | 1989-08-31 | 1995-07-29 |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom LIKE "______";
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
| Chirpy | Gwen | oiseau | m | 1996-03-10 | NULL |
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
| Bowser | Diane | chien | m | 1989-08-31 | 1995-07-29 |
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Regex:
|
||||||
|
|
||||||
|
`REGEXP`
|
||||||
|
|
||||||
|
`NOT REGEXP`
|
||||||
|
|
||||||
|
Quelques caractéristiques des expressions régulières étendues sont :
|
||||||
|
|
||||||
|
- Le caractère ‘.’ trouve n'importe quel caractère.
|
||||||
|
- Une classe de caractères ‘[...]’ trouve n'importe quel caractère contenu entre les crochets. Par exemple, la classe de caractères ‘[abc]’ trouve le caractère ‘a’, ‘b’, ou ‘c’. Pour définir un intervalle de caractères, utilisez un trait d'union. La classe de caractères ‘[a-z]’ trouvera n'importe quel caractère minuscule, tout comme la classe ‘[0-9]’ trouvera n'importe quel nombre.
|
||||||
|
- Le caractère ‘*’ trouvera aucune ou plus d'instances du caractère qui le précède. Par exemple, ‘x*’ trouvera n'importe quel nombre de fois le caractère ‘x’, ‘[0-9]*’ trouvera n'importe quel nombre et ‘.*’ trouvera n'importe quel nombre de fois n'importe quel caractère.
|
||||||
|
- Le modèle est trouvé s'il se produit n'importe où dans la valeur testée. (Les modèles SQL ne sont trouvés que s'ils sont présents en valeur entière.)
|
||||||
|
- Pour ancrer un modèle de sorte qu'il soit trouvé au début ou à la fin de valeur testée, utilisez ‘^’ au début ou bien ‘$’ à la fin du modèle.
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom REGEXP "y$";
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| Chirpy | Gwen | oiseau | m | 1996-03-10 | NULL |
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom REGEXP "^f";
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
+--------+--------+--------+------+------------+------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom REGEXP "b";
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
|
||||||
|
| Bowser | Diane | chien | m | 1989-08-31 | 1995-07-29 |
|
||||||
|
+----------+--------+---------+------+------------+------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT * FROM animal WHERE nom REGEXP "^......$";
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
| nom | maitre | espece | sexe | naissance | mort |
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
| Chirpy | Gwen | oiseau | m | 1996-03-10 | NULL |
|
||||||
|
| Fluffy | Harold | chat | m | 1984-11-10 | NULL |
|
||||||
|
| Bowser | Diane | chien | m | 1989-08-31 | 1995-07-29 |
|
||||||
|
+--------+--------+--------+------+------------+------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Compter les lignes:
|
||||||
|
|
||||||
|
`COUNT()`
|
||||||
|
|
||||||
|
La fonction COUNT() compte le nombre de résultats non NULL
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT COUNT(*) FROM animal;
|
||||||
|
+----------+
|
||||||
|
| COUNT(*) |
|
||||||
|
+----------+
|
||||||
|
| 5 |
|
||||||
|
+----------+
|
||||||
|
```
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> SELECT maitre, COUNT(*) FROM animal GROUP BY maitre;
|
||||||
|
+--------+----------+
|
||||||
|
| maitre | COUNT(*) |
|
||||||
|
+--------+----------+
|
||||||
|
| Benny | 1 |
|
||||||
|
| Diane | 2 |
|
||||||
|
| Gwen | 1 |
|
||||||
|
| Harold | 1 |
|
||||||
|
+--------+----------+
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Modifier une donnée:
|
||||||
|
|
||||||
|
`UPDATE table SET colonne1="x" WHERE colonne2="y";`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> UPDATE animal SET naissance = "1989-08-31" WHERE nom = "Bowser";
|
||||||
|
Query OK, 1 row affected (0.006 sec)
|
||||||
|
Rows matched: 1 Changed: 1 Warnings: 0
|
||||||
|
```
|
||||||
|
|
||||||
173
docs/MySQL/tables.md
Normal file
173
docs/MySQL/tables.md
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
# Tables:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Voir les tables de la base courante:
|
||||||
|
|
||||||
|
`mysql [database]> SHOW TABLES;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [wordpress]> SHOW TABLES;
|
||||||
|
+-----------------------+
|
||||||
|
| Tables_in_wordpress |
|
||||||
|
+-----------------------+
|
||||||
|
| wp_commentmeta |
|
||||||
|
| wp_comments |
|
||||||
|
| wp_links |
|
||||||
|
| wp_options |
|
||||||
|
| wp_postmeta |
|
||||||
|
| wp_posts |
|
||||||
|
| wp_term_relationships |
|
||||||
|
| wp_term_taxonomy |
|
||||||
|
| wp_termmeta |
|
||||||
|
| wp_terms |
|
||||||
|
| wp_usermeta |
|
||||||
|
| wp_users |
|
||||||
|
+-----------------------+
|
||||||
|
12 rows in set (0.003 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Structure d’une table:
|
||||||
|
|
||||||
|
`mysql [database]> DESCRIBE table;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [wordpress]> DESCRIBE wp_terms;
|
||||||
|
+------------+---------------------+------+-----+---------+----------------+
|
||||||
|
| Field | Type | Null | Key | Default | Extra |
|
||||||
|
+------------+---------------------+------+-----+---------+----------------+
|
||||||
|
| term_id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
|
||||||
|
| name | varchar(200) | NO | MUL | | |
|
||||||
|
| slug | varchar(200) | NO | MUL | | |
|
||||||
|
| term_group | bigint(10) | NO | | 0 | |
|
||||||
|
+------------+---------------------+------+-----+---------+----------------+
|
||||||
|
4 rows in set (0.006 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Renommer une table:
|
||||||
|
|
||||||
|
`mysql [database]> ALTER TABLE table AS new_table;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [zenphoto]> ALTER TABLE _tags RENAME AS _new-tags;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Créer une table:
|
||||||
|
|
||||||
|
`mysql [database]> CREATE TABLE table;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> CREATE TABLE animal (nom VARCHAR(20), maitre VARCHAR(20), espece VARCHAR(20), sexe CHAR(1), naissance DATE, mort DATE);
|
||||||
|
Query OK, 0 rows affected (0.138 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Charger des données dans une table:
|
||||||
|
|
||||||
|
`mysql [database]> INSERT INTO table VALUES ('','');`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> INSERT INTO animal VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
|
||||||
|
Query OK, 1 row affected (0.012 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
`mysql [database]> LOAD DATA LOCAL INFILE "file.txt" INTO TABLE table;`
|
||||||
|
|
||||||
|
```mariadb
|
||||||
|
MariaDB [mydatabase]> LOAD DATA LOCAL INFILE "evenements.txt" INTO TABLE evenement;
|
||||||
|
Query OK, 11 rows affected, 3 warnings (0.017 sec)
|
||||||
|
Records: 11 Deleted: 0 Skipped: 0 Warnings: 3
|
||||||
|
```
|
||||||
|
|
||||||
|
Le fichier .txt doit être dans le dossier qui contient les tables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/opt/homebrew/var/mysql/mydatabase master 13:26:16
|
||||||
|
❯ ls -la
|
||||||
|
total 208
|
||||||
|
drwx------ 8 bruno admin 256 sep 6 13:26 .
|
||||||
|
drwxr-xr-x 18 bruno admin 576 sep 4 08:00 ..
|
||||||
|
-rw-rw---- 1 bruno admin 741 sep 4 09:17 animal.frm
|
||||||
|
-rw-rw---- 1 bruno admin 98304 sep 4 09:17 animal.ibd
|
||||||
|
-rw-rw---- 1 bruno admin 67 sep 4 08:00 db.opt
|
||||||
|
-rw-rw---- 1 bruno admin 1377 sep 6 11:18 evenement.frm
|
||||||
|
-rw-rw---- 1 bruno admin 98304 sep 6 11:18 evenement.ibd
|
||||||
|
-rw-r--r-- 1 bruno admin 529 sep 6 13:26 evenements.txt
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Vérification des tables :
|
||||||
|
|
||||||
|
<u>2 solutions:</u>
|
||||||
|
|
||||||
|
**1) CHECK TABLE table;**
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [wordpress]> CHECK TABLE wp_terms;
|
||||||
|
+--------------------+-------+----------+----------+
|
||||||
|
| Table | Op | Msg_type | Msg_text |
|
||||||
|
+--------------------+-------+----------+----------+
|
||||||
|
| wordpress.wp_terms | check | status | OK |
|
||||||
|
+--------------------+-------+----------+----------+
|
||||||
|
1 row in set (0.008 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**2) [mysqlcheck](https://mariadb.com/kb/en/library/mysqlcheck/)**
|
||||||
|
|
||||||
|
mysqlcheck verrouille chaque table en lecture seule (la base est alors inaccessible pour les autres processus pendant ce temps) pour vérification ou réparation.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ mysqlcheck -u root -ppassword wordpress
|
||||||
|
wordpress.wp_commentmeta OK
|
||||||
|
wordpress.wp_comments OK
|
||||||
|
wordpress.wp_links OK
|
||||||
|
wordpress.wp_options OK
|
||||||
|
wordpress.wp_postmeta OK
|
||||||
|
wordpress.wp_posts OK
|
||||||
|
wordpress.wp_term_relationships OK
|
||||||
|
wordpress.wp_term_taxonomy OK
|
||||||
|
wordpress.wp_termmeta OK
|
||||||
|
wordpress.wp_terms OK
|
||||||
|
wordpress.wp_usermeta OK
|
||||||
|
wordpress.wp_users OK
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Optimiser:
|
||||||
|
|
||||||
|
Les bases InnoDB ne supportent pas l’option OPTIMIZE.
|
||||||
|
|
||||||
|
A la place,MySQL crée une nouvelle table, y copie toutes les lignes, efface l’ancienne table, renomme la nouvelle et lance ANALYSE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ mysqlcheck -u root -psncfp1p2 -o --all-databases
|
||||||
|
mysql.column_stats Table is already up to date
|
||||||
|
mysql.columns_priv Table is already up to date
|
||||||
|
mysql.db OK
|
||||||
|
mysql.event Table is already up to date
|
||||||
|
...
|
||||||
|
wordpress.wp_commentmeta
|
||||||
|
note : Table does not support optimize, doing recreate + analyze instead
|
||||||
|
status : OK
|
||||||
|
wordpress.wp_comments
|
||||||
|
note : Table does not support optimize, doing recreate + analyze instead
|
||||||
|
status : OK
|
||||||
|
wordpress.wp_links
|
||||||
|
note : Table does not support optimize, doing recreate + analyze instead
|
||||||
|
status : OK
|
||||||
|
```
|
||||||
|
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
# Reset Expired root Password for MySQL 5.7 on Mac OS X
|
# Trucs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Reset Expired root Password for MySQL 5.7 on Mac OS X
|
||||||
|
|
||||||
1. Arrêter MySQL (PrefPane)
|
1. Arrêter MySQL (PrefPane)
|
||||||
|
|
||||||
@@ -29,3 +33,13 @@ mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
|
|||||||
$ mysql -u root -p Enter password:
|
$ mysql -u root -p Enter password:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Fix the 2002 MySQL Socket error (OSX)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo mkdir /var/mysql
|
||||||
|
|
||||||
|
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
|
||||||
|
```
|
||||||
|
|
||||||
93
docs/MySQL/type_bases.md
Normal file
93
docs/MySQL/type_bases.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Types de bases (moteur de stockage):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### [InnoDB](https://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html)
|
||||||
|
|
||||||
|
Conseil: enable innodb_file_per_table = 1 option to put indexes and data for individual tables into distinct files.
|
||||||
|
|
||||||
|
Requête pour trouver les tables InnoDB parmi toutes les bases:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
mysql> SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'innodb';
|
||||||
|
```
|
||||||
|
|
||||||
|
Constitution de Mysql (par défaut):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bruno@silverbook:/usr/local/var/mysql$
|
||||||
|
-rw-r----- 1 bruno admin 15114 28 nov 08:08 ib_buffer_pool
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 3 déc 10:35 ib_logfile0
|
||||||
|
-rw-rw---- 1 bruno admin 50331648 24 oct 12:51 ib_logfile1
|
||||||
|
-rw-rw---- 1 bruno admin 79691776 3 déc 10:35 ibdata1
|
||||||
|
-rw-rw---- 1 bruno admin 12582912 28 nov 16:53 ibtmp1
|
||||||
|
-rw-rw---- 1 bruno admin 1272770 3 déc 10:35 silverbook.home.err
|
||||||
|
-rw-rw---- 1 bruno admin 5 28 nov 16:53 silverbook.home.pid
|
||||||
|
```
|
||||||
|
|
||||||
|
- ibdata1: fichier de 10Mo extensible. InnoDB y stocke tout (bases,tables, index...) pour éviter la fragmentation.
|
||||||
|
- ib_logfile0, ib_logfile1: 2 fichiers log de 5Mo.
|
||||||
|
- ibtmp1
|
||||||
|
- ib_buffer_pool:
|
||||||
|
- silverbook.home.err: fichier log des erreurs
|
||||||
|
|
||||||
|
http://forum.wgpower.net/technique/innodb-fichier-ibdata1-trop-37009_1.html
|
||||||
|
|
||||||
|
https://vdachev.net/2007/02/22/mysql-reducing-ibdata1/
|
||||||
|
|
||||||
|
https://stackoverflow.com/questions/3456159/how-to-shrink-purge-ibdata1-file-in-mysql
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### [MyISAM](https://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Connaitre le type de bases par défaut:
|
||||||
|
|
||||||
|
`mysql> SHOW ENGINES;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SHOW ENGINES;
|
||||||
|
+--------------------+---------+-------------------------------------------------------------------------------------------------+--------------+------+------------+
|
||||||
|
| Engine | Support | Comment | Transactions | XA | Savepoints |
|
||||||
|
+--------------------+---------+-------------------------------------------------------------------------------------------------+--------------+------+------------+
|
||||||
|
| CSV | YES | Stores tables as CSV files | NO | NO | NO |
|
||||||
|
| MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
|
||||||
|
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
|
||||||
|
| Aria | YES | Crash-safe tables with MyISAM heritage. Used for internal temporary tables and privilege tables | NO | NO | NO |
|
||||||
|
| MyISAM | YES | Non-transactional engine with good performance and small data footprint | NO | NO | NO |
|
||||||
|
| SEQUENCE | YES | Generated tables filled with sequential values | YES | NO | YES |
|
||||||
|
| InnoDB | DEFAULT | Supports transactions, row-level locking, foreign keys and encryption for tables | YES | YES | YES |
|
||||||
|
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
<u>InnoDB est le moteur par défaut.</u>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### ENGINE utilisé pour une table:
|
||||||
|
|
||||||
|
`mysql> SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'database';`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'wordpress';
|
||||||
|
+-----------------------+--------+
|
||||||
|
| TABLE_NAME | ENGINE |
|
||||||
|
+-----------------------+--------+
|
||||||
|
| wp_terms | InnoDB |
|
||||||
|
| wp_commentmeta | InnoDB |
|
||||||
|
| wp_term_taxonomy | InnoDB |
|
||||||
|
| wp_usermeta | InnoDB |
|
||||||
|
| wp_options | InnoDB |
|
||||||
|
| wp_users | InnoDB |
|
||||||
|
| wp_term_relationships | InnoDB |
|
||||||
|
| wp_links | InnoDB |
|
||||||
|
| wp_postmeta | InnoDB |
|
||||||
|
| wp_termmeta | InnoDB |
|
||||||
|
| wp_comments | InnoDB |
|
||||||
|
| wp_posts | InnoDB |
|
||||||
|
+-----------------------+--------+
|
||||||
|
```
|
||||||
|
|
||||||
71
docs/MySQL/users.md
Normal file
71
docs/MySQL/users.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# Utilisateurs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Voir tous les utilisateurs MySQL:
|
||||||
|
|
||||||
|
ainsi que les hosts auxquels ils ont le droit de se connecter.
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SELECT user,host from mysql.user;
|
||||||
|
+-----------------+-----------+
|
||||||
|
| User | Host |
|
||||||
|
+-----------------+-----------+
|
||||||
|
| adm_wp | localhost |
|
||||||
|
| bruno | localhost |
|
||||||
|
| mariadb.sys | localhost |
|
||||||
|
| mysqlbackupuser | localhost |
|
||||||
|
| newuser | localhost |
|
||||||
|
| root | localhost |
|
||||||
|
+-----------------+-----------+
|
||||||
|
6 rows in set (0.001 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
on affiche également les mots-de-passe.
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> SELECT host,user,password FROM mysql.user;
|
||||||
|
|
||||||
|
# MySQL 5.7+
|
||||||
|
MariaDB [(none)]> SELECT host,user,authentication_string FROM mysql.user;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Créer un utilisateur:
|
||||||
|
|
||||||
|
`mysql> CREATE USER theuser;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> CREATE USER 'theuser'@'localhost' IDENTIFIED BY 'the_password';
|
||||||
|
```
|
||||||
|
|
||||||
|
Lui donner tous les droits:
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> GRANT ALL PRIVILEGES ON * . * TO 'theuser'@'localhost';
|
||||||
|
MariaDB [(none)]> FLUSH PRIVILEGES
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Supprimer un utilisateur:
|
||||||
|
|
||||||
|
`mysql> DROP USER theuser;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> DROP USER 'theuser'@'localhost';
|
||||||
|
Query OK, 0 rows affected (0.023 sec)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Renommer un utilisateur:
|
||||||
|
|
||||||
|
`mysql> RENAME USER theuser;`
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
MariaDB [(none)]> RENAME USER 'theuser'@'localhost' TO 'the_user'@'localhost';
|
||||||
|
Query OK, 0 rows affected (0.038 sec)
|
||||||
|
```
|
||||||
|
|
||||||
@@ -37,5 +37,7 @@ Désinstaller un module:
|
|||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
❯ Uninstall-Module -Name posh-git
|
❯ Uninstall-Module -Name posh-git
|
||||||
|
|
||||||
|
❯ Uninstall-Module posh-git -Force -Verbose
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,31 @@
|
|||||||
# Trucs
|
# Trucs
|
||||||
|
|
||||||
Ouvrir Windows Terminal en 3 panneaux:
|
#### Ouvrir Windows Terminal en 3 panneaux:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
wt -p "Debian" `; split-pane -p "PowerShell 7" `; split-pane -p "Invite de commandes"
|
wt -p "Debian" `; split-pane -p "PowerShell 7" `; split-pane -p "Invite de commandes"
|
||||||
```
|
```
|
||||||
|
|
||||||
Ouvrir en 3 onglets dans Windows Terminal:
|
#### Ouvrir en 3 onglets dans Windows Terminal:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
wt -p "Debian" `; new-tab -p "PowerShell 7" `; new-tab -p "Invite de commandes"
|
wt -p "Debian" `; new-tab -p "PowerShell 7" `; new-tab -p "Invite de commandes"
|
||||||
```
|
```
|
||||||
|
|
||||||
Palette de commande:
|
#### Palette de commande:
|
||||||
|
|
||||||
`Ctrl + Shift + P`
|
`Ctrl + Shift + P`
|
||||||
|
|
||||||
Thèmes:
|
#### Thèmes:
|
||||||
|
|
||||||
https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
|
https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
|
||||||
|
|
||||||
https://ohmyposh.dev/docs/
|
https://ohmyposh.dev/docs/
|
||||||
|
|
||||||
|
#### Ne pas afficher de messages au lancement de PowerShell:
|
||||||
|
|
||||||
|
Lancer avec l'option --nolog: `powerShell.exe --nolog`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Ouvrir une nouvelle fenêtre Powershell en administrateur:
|
#### Ouvrir une nouvelle fenêtre Powershell en administrateur:
|
||||||
|
|||||||
@@ -275,10 +275,18 @@ https://korben.info/linux-wsl-gui-interface-graphique-windows-10.html
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
#### Installer un X11-server:
|
||||||
sudo apt install python3 python3-pip ipython3
|
|
||||||
|
```powershell
|
||||||
|
choco install vcxsrv
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ajouter au `.bashrc` ou `.zshrc`:
|
||||||
|
|
||||||
|
`export DISPLAY=:0`
|
||||||
|
|
||||||
|
Installer gvim (sudo apt-get install gvim) pour tester.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Navigation dans les dossiers/fichiers:
|
#### Navigation dans les dossiers/fichiers:
|
||||||
|
|||||||
@@ -376,6 +376,18 @@ $ uname --release
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Windows Toolbar Launcher:
|
||||||
|
|
||||||
|
https://github.com/cascadium/wsl-windows-toolbar-launcher
|
||||||
|
|
||||||
|
```bash
|
||||||
|
2021-08-31 13:13:54,707[INFO]: Finished creating 25 shortcuts!
|
||||||
|
2021-08-31 13:13:54,708[INFO]: Before raising an issue, make sure you have Xming / X410 etc set up in your .bashrc.
|
||||||
|
2021-08-31 13:13:54,708[INFO]: Right click on the toolbar, then select Toolbars -> New toolbar... and select the directory '/mnt/c/Users/bruno/.config/wsl-windows-toolbar-launcher/menus/WSL'.
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
https://opticos.github.io/openinwsl/
|
https://opticos.github.io/openinwsl/
|
||||||
|
|
||||||
https://opticos.github.io/gwsl/
|
https://opticos.github.io/gwsl/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Homebrew-Cask
|
# Homebrew-Cask
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -887,7 +887,7 @@ Ajouter `PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"` et `PATH="/usr/lo
|
|||||||
|
|
||||||
### Erreurs:
|
### Erreurs:
|
||||||
|
|
||||||
**`require': cannot load such file -- active_support/core_ext/object/blank (LoadError)**
|
#### 1. `require': cannot load such file -- active_support/core_ext/object/blank (LoadError)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Erreur sur chaque commande brew...
|
# Erreur sur chaque commande brew...
|
||||||
@@ -903,7 +903,7 @@ Traceback (most recent call last):
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Lancer **brew update-reset** pour réparer:
|
<u>Solution:</u> Lancer **brew update-reset** pour réparer:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
% brew update-reset
|
% brew update-reset
|
||||||
@@ -932,6 +932,105 @@ Your branch is up to date with 'origin/master'.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 2. Some taps are not on the default git origin branch
|
||||||
|
|
||||||
|
`brew doctor` dit:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Warning: Some taps are not on the default git origin branch and may not receive
|
||||||
|
updates. If this is a surprise to you, check out the default branch with:
|
||||||
|
git -C $(brew --repo shivammathur/extensions) checkout master
|
||||||
|
```
|
||||||
|
|
||||||
|
Lancer `git -C $(brew --repo shivammathur/extensions) checkout master`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git -C $(brew --repo shivammathur/extensions) checkout master
|
||||||
|
.github/scripts/edit.sh: needs merge
|
||||||
|
.github/workflows/tests-all.yml: needs merge
|
||||||
|
Formula/vips@7.0.rb: needs merge
|
||||||
|
Formula/vips@7.1.rb: needs merge
|
||||||
|
Formula/vips@7.2.rb: needs merge
|
||||||
|
Formula/vips@7.3.rb: needs merge
|
||||||
|
Formula/vips@7.4.rb: needs merge
|
||||||
|
Formula/vips@8.0.rb: needs merge
|
||||||
|
Formula/vips@8.1.rb: needs merge
|
||||||
|
error: vous devez d'abord résoudre votre index courant
|
||||||
|
```
|
||||||
|
|
||||||
|
<u>Solution:</u>
|
||||||
|
|
||||||
|
If you want to keep the changes you made to those formula there is nothing you need to do. `brew doctor` only provides information and if you don't have problems you don't need to change anything.
|
||||||
|
|
||||||
|
If you want to discard the changes, the easiest way would be:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git -C $(brew --repo shivammathur/extensions) add .
|
||||||
|
git -C $(brew --repo shivammathur/extensions) reset --hard origin/master
|
||||||
|
git -C $(brew --repo shivammathur/extensions) checkout master
|
||||||
|
```
|
||||||
|
|
||||||
|
La dernière commande dit:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
HEAD's previous position was on 13d8b20 imap@8.1: update 8.1.0 bottle.
|
||||||
|
Switching to the 'master' branch
|
||||||
|
Your branch and 'origin / master' have diverged,
|
||||||
|
and have 1 and 54 different commits each respectively.
|
||||||
|
(use "git pull" to merge the remote branch into yours)
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour corriger, lancer:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git -C $(brew --repo shivammathur/extensions) reset --hard origin/master
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 3. fatal: It seems that there is already a rebase-merge directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fatal: It seems that there is already a rebase-merge directory, and
|
||||||
|
I wonder if you are in the middle of another rebase. If that is the case, please try
|
||||||
|
git rebase (--continue | --abort | --skip)
|
||||||
|
If that is not the case, please
|
||||||
|
rm -fr ".git/rebase-merge"
|
||||||
|
and run me again. I am stopping in case you still have something valuable there.
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour corriger, lancer:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew update-reset
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Réinstaller Homebrew
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd $HOME
|
||||||
|
|
||||||
|
brew bundle dump
|
||||||
|
brew bundle cleanup
|
||||||
|
|
||||||
|
# Désinstaller Homebrew
|
||||||
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
|
||||||
|
|
||||||
|
cd $(brew --prefix)
|
||||||
|
# Supprimer manuellement les restes
|
||||||
|
|
||||||
|
cd $HOME
|
||||||
|
|
||||||
|
# Réinstaller Homebrew
|
||||||
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
|
||||||
|
brew bundle install
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Cask:
|
### Cask:
|
||||||
|
|
||||||
### [:fa-link: Homebrew-Cask](brew-cask.md)
|
### [:fa-link: Homebrew-Cask](brew-cask.md)
|
||||||
@@ -162,6 +162,8 @@ $ up_venv mkdocs_env
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ pip3 install django
|
$ pip3 install django
|
||||||
|
|
||||||
|
$ python3 -m pip install dango
|
||||||
```
|
```
|
||||||
|
|
||||||
Les modules sont ici:
|
Les modules sont ici:
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ alias bra='brew services restart httpd'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### [=> Installer PHP](php_M1.md)
|
### [=> Installer PHP](php.md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
132
docs/macos/webserver/mod-php.md
Normal file
132
docs/macos/webserver/mod-php.md
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# Configurer PHP (mod-php)(Apache 2.2-)
|
||||||
|
|
||||||
|
#### php.ini
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /usr/local/etc/php/7.4/php.ini
|
||||||
|
$ nano /usr/local/etc/php/8.0/php.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /opt/homebrew/etc/php/7.4/php.ini
|
||||||
|
$ nano /opt/homebrew/etc/php/8.0/php.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Date]
|
||||||
|
; Defines the default timezone used by the date functions
|
||||||
|
; http://php.net/date.timezone
|
||||||
|
date.timezone = Europe/Paris
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Error handling and logging ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
error_log = php_errors.log
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;
|
||||||
|
; Resource Limits ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
memory_limit = 512M
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Modifier le httpd.conf:
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /usr/local/etc/httpd/httpd.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /opt/homebrew/etc/httpd/httpd.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Dans *httpd.conf*, ajouter les lignes:
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```http
|
||||||
|
LoadModule php7_module /usr/localopt/php@7.4/lib/httpd/modules/libphp7.so
|
||||||
|
#LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```http
|
||||||
|
LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so
|
||||||
|
#LoadModule php_module /opt/homebrew/opt/php@8.0/lib/httpd/modules/libphp.so
|
||||||
|
```
|
||||||
|
|
||||||
|
intel / M1:
|
||||||
|
|
||||||
|
Remplacer:
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.html
|
||||||
|
</IfModule>
|
||||||
|
```
|
||||||
|
|
||||||
|
par
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.php index.html
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
SetHandler application/x-httpd-php
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Changer de version:
|
||||||
|
|
||||||
|
#### Méthode 1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ brew unlink php && brew link --overwrite --force php@7.4
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Méthode 2:
|
||||||
|
|
||||||
|
*PHP switcher script*
|
||||||
|
|
||||||
|
Installation Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp
|
||||||
|
$ chmod +x /usr/local/bin/sphp
|
||||||
|
```
|
||||||
|
|
||||||
|
Installation Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl -L https://raw.githubusercontent.com/vadimbk/sphp/main/sphp > /opt/homebrew/bin/sphp
|
||||||
|
$ chmod +x /opt/homebrew/bin/sphp
|
||||||
|
```
|
||||||
|
|
||||||
|
Utilisation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sphp 7.4
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2,24 +2,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Connexion à la base:
|
|
||||||
|
|
||||||
#### Se connecter à MySQL:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysql -u root -p
|
|
||||||
Enter password:
|
|
||||||
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
|
||||||
Your MariaDB connection id is 18
|
|
||||||
Server version: 10.3.11-MariaDB Homebrew
|
|
||||||
|
|
||||||
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
|
||||||
|
|
||||||
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
|
||||||
|
|
||||||
MariaDB [(none)]>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Connexion à la base wordpress4 par l’utilisateur root:
|
#### Connexion à la base wordpress4 par l’utilisateur root:
|
||||||
@@ -43,513 +25,11 @@ MariaDB [wordpress4]>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Quitter MySQL:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [wordpress4]> exit
|
|
||||||
Bye
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Types de bases (moteur de stockage):
|
|
||||||
|
|
||||||
[InnoDB](https://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html)
|
|
||||||
|
|
||||||
Conseil: enable innodb_file_per_table = 1 option to put indexes and data for individual tables into distinct files.
|
|
||||||
|
|
||||||
Requête pour trouver les tables InnoDB parmi toutes les bases:
|
|
||||||
|
|
||||||
```mysql
|
|
||||||
mysql> SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'innodb';
|
|
||||||
```
|
|
||||||
|
|
||||||
Constitution de Mysql (par défaut):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bruno@silverbook:/usr/local/var/mysql$
|
|
||||||
-rw-r----- 1 bruno admin 15114 28 nov 08:08 ib_buffer_pool
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 3 déc 10:35 ib_logfile0
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 24 oct 12:51 ib_logfile1
|
|
||||||
-rw-rw---- 1 bruno admin 79691776 3 déc 10:35 ibdata1
|
|
||||||
-rw-rw---- 1 bruno admin 12582912 28 nov 16:53 ibtmp1
|
|
||||||
-rw-rw---- 1 bruno admin 1272770 3 déc 10:35 silverbook.home.err
|
|
||||||
-rw-rw---- 1 bruno admin 5 28 nov 16:53 silverbook.home.pid
|
|
||||||
```
|
|
||||||
|
|
||||||
- ibdata1: fichier de 10Mo extensible. InnoDB y stocke tout (bases,tables, index...) pour éviter la fragmentation.
|
|
||||||
- ib_logfile0, ib_logfile1: 2 fichiers log de 5Mo.
|
|
||||||
- ibtmp1
|
|
||||||
- ib_buffer_pool:
|
|
||||||
- silverbook.home.err: fichier log des erreurs
|
|
||||||
|
|
||||||
http://forum.wgpower.net/technique/innodb-fichier-ibdata1-trop-37009_1.html
|
|
||||||
|
|
||||||
https://vdachev.net/2007/02/22/mysql-reducing-ibdata1/
|
|
||||||
|
|
||||||
https://stackoverflow.com/questions/3456159/how-to-shrink-purge-ibdata1-file-in-mysql
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[MyISAM](https://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Connaitre le type de bases par défaut:
|
|
||||||
|
|
||||||
<u>mysql> show engine;</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [(none)]> show engines;
|
|
||||||
|
|
||||||
+--------------------+---------+----------------------------------------------------------------------------------+--------------+------+------------+
|
|
||||||
|
|
||||||
| Engine | Support | Comment | Transactions | XA | Savepoints |
|
|
||||||
|
|
||||||
+--------------------+---------+----------------------------------------------------------------------------------+--------------+------+------------+
|
|
||||||
|
|
||||||
| MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
|
|
||||||
|
|
||||||
| CSV | YES | Stores tables as CSV files | NO | NO | NO |
|
|
||||||
|
|
||||||
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
|
|
||||||
|
|
||||||
| MyISAM | YES | Non-transactional engine with good performance and small data footprint | NO | NO | NO |
|
|
||||||
|
|
||||||
| Aria | YES | Crash-safe tables with MyISAM heritage | NO | NO | NO |
|
|
||||||
|
|
||||||
| InnoDB | DEFAULT | Supports transactions, row-level locking, foreign keys and encryption for tables | YES | YES | YES |
|
|
||||||
|
|
||||||
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
|
|
||||||
|
|
||||||
| SEQUENCE | YES | Generated tables filled with sequential values | YES | NO | YES |
|
|
||||||
|
|
||||||
+--------------------+---------+----------------------------------------------------------------------------------+--------------+------+------------+
|
|
||||||
|
|
||||||
8 rows in set (0.007 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### ENGINE utilisé pour une table:
|
|
||||||
|
|
||||||
<u>mysql> SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'database';</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [(none)]> SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'zenphoto';
|
|
||||||
|
|
||||||
+------------------+--------+
|
|
||||||
| TABLE_NAME | ENGINE |
|
|
||||||
+------------------+--------+
|
|
||||||
| _menu | InnoDB |
|
|
||||||
| .tags | InnoDB |
|
|
||||||
| .plugin_storage | InnoDB |
|
|
||||||
| _images | InnoDB |
|
|
||||||
| .pages | MyISAM |
|
|
||||||
| .menu | InnoDB |
|
|
||||||
| _plugin_storage | InnoDB |
|
|
||||||
| .admin_to_object | InnoDB |
|
|
||||||
| _tags | InnoDB |
|
|
||||||
.../...
|
|
||||||
| .captcha | InnoDB |
|
|
||||||
| .news | InnoDB |
|
|
||||||
| .comments | MyISAM |
|
|
||||||
| _admin_to_object | InnoDB |
|
|
||||||
| _comments | InnoDB |
|
|
||||||
| _pages | InnoDB |
|
|
||||||
+------------------+--------+
|
|
||||||
|
|
||||||
32 rows in set (0.012 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Bases:
|
|
||||||
|
|
||||||
#### Voir toutes les bases:
|
|
||||||
|
|
||||||
<u>mysql> SHOW DATABASES;</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [(none)]> SHOW DATABASES;
|
|
||||||
|
|
||||||
+--------------------+
|
|
||||||
| Database |
|
|
||||||
+--------------------+
|
|
||||||
| funnymac |
|
|
||||||
| ghost_prod |
|
|
||||||
| information_schema |
|
|
||||||
| mgpt |
|
|
||||||
| mysql |
|
|
||||||
| performance_schema |
|
|
||||||
| phpmyadmin |
|
|
||||||
| piwik |
|
|
||||||
| python |
|
|
||||||
| ssi |
|
|
||||||
| wordpress4 |
|
|
||||||
| wordpress5 |
|
|
||||||
| xhprof |
|
|
||||||
| xhprof_gui |
|
|
||||||
| yeswiki |
|
|
||||||
| zenphoto |
|
|
||||||
+--------------------+
|
|
||||||
|
|
||||||
16 rows in set (0.007 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Utiliser une base existante:
|
|
||||||
|
|
||||||
<u>mysql> USE database;</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [(none)]> USE ssi
|
|
||||||
|
|
||||||
Reading table information for completion of table and column names
|
|
||||||
|
|
||||||
You can turn off this feature to get a quicker startup with -A
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Database changed
|
|
||||||
|
|
||||||
MariaDB [ssi]>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Supprimer une base:
|
|
||||||
|
|
||||||
<u>mysql> DROP DATABASE database</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [(none)]> DROP DATABASE zenphoto
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Tables:
|
|
||||||
|
|
||||||
#### Voir les tables de la base courante:
|
|
||||||
|
|
||||||
<u>mysql [database]> SHOW TABLES;</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [zenphoto]> SHOW TABLES;
|
|
||||||
|
|
||||||
+--------------------+
|
|
||||||
| Tables_in_zenphoto |
|
|
||||||
+--------------------+
|
|
||||||
| .admin_to_object |
|
|
||||||
| .administrators |
|
|
||||||
| .albums |
|
|
||||||
| .captcha |
|
|
||||||
| .comments |
|
|
||||||
| .images |
|
|
||||||
.../...
|
|
||||||
| _news |
|
|
||||||
| _news2cat |
|
|
||||||
| _news_categories |
|
|
||||||
| _obj_to_tag |
|
|
||||||
| _options |
|
|
||||||
| _pages |
|
|
||||||
| _plugin_storage |
|
|
||||||
| _search_cache |
|
|
||||||
| _tags |
|
|
||||||
+--------------------+
|
|
||||||
|
|
||||||
32 rows in set (0.000 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Structure d’une table:
|
|
||||||
|
|
||||||
<u>mysql [database]> DESCRIBE table;</u>
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [zenphoto]> DESCRIBE _tags;
|
|
||||||
|
|
||||||
+-------+------------------+------+-----+---------+----------------+
|
|
||||||
| Field | Type | Null | Key | Default | Extra |
|
|
||||||
+-------+------------------+------+-----+---------+----------------+
|
|
||||||
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
|
|
||||||
| name | varchar(255) | NO | UNI | NULL | |
|
|
||||||
+-------+------------------+------+-----+---------+----------------+
|
|
||||||
|
|
||||||
2 rows in set (0.030 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Renommer une table:
|
|
||||||
|
|
||||||
mysql [database]> ALTER TABLE table AS new_table;
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [zenphoto]> ALTER TABLE _tags RENAME AS _new-tags;
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Vérification des tables :
|
|
||||||
|
|
||||||
<u>2 solutions:</u>
|
|
||||||
|
|
||||||
**1) CHECK TABLE table;**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [zenphoto]> CHECK TABLE _tags;
|
|
||||||
|
|
||||||
+----------------+-------+----------+----------+
|
|
||||||
| Table | Op | Msg_type | Msg_text |
|
|
||||||
+----------------+-------+----------+----------+
|
|
||||||
| zenphoto._tags | check | status | OK |
|
|
||||||
+----------------+-------+----------+----------+
|
|
||||||
|
|
||||||
1 row in set (0.043 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**2) [mysqlcheck](https://mariadb.com/kb/en/library/mysqlcheck/)**
|
|
||||||
|
|
||||||
mysqlcheck verrouille chaque table en lecture seule (la base est alors inaccessible pour les autres processus pendant ce temps) pour vérification ou réparation.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysqlcheck -u root -ppassword zenphoto
|
|
||||||
|
|
||||||
zenphoto..admin_to_object OK
|
|
||||||
zenphoto..administrators OK
|
|
||||||
zenphoto..albums OK
|
|
||||||
zenphoto..captcha OK
|
|
||||||
zenphoto..comments OK
|
|
||||||
zenphoto..images OK
|
|
||||||
zenphoto..menu OK
|
|
||||||
|
|
||||||
.../...
|
|
||||||
|
|
||||||
zenphoto._news2cat OK
|
|
||||||
zenphoto._news_categories OK
|
|
||||||
zenphoto._obj_to_tag OK
|
|
||||||
zenphoto._options OK
|
|
||||||
zenphoto._pages OK
|
|
||||||
zenphoto._plugin_storage OK
|
|
||||||
zenphoto._search_cache OK
|
|
||||||
zenphoto._tags OK
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Optimiser:
|
|
||||||
|
|
||||||
Les bases InnoDB ne supportent pas l’option OPTIMIZE.
|
|
||||||
|
|
||||||
A la place,MySQL crée une nouvelle table, y copie toutes les lignes, efface l’ancienne table, renomme la nouvelle et lance ANALYSE
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mysqlcheck -u root -ppassword -o --all-databases
|
|
||||||
|
|
||||||
funnymac.download OK
|
|
||||||
funnymac.downloads OK
|
|
||||||
funnymac.eggs OK
|
|
||||||
funnymac.ipod OK
|
|
||||||
funnymac.ipod_news OK
|
|
||||||
funnymac.ipod_vers OK
|
|
||||||
funnymac.liens OK
|
|
||||||
funnymac.livre OK
|
|
||||||
funnymac.note OK
|
|
||||||
funnymac.numeric_info Table is already up to date
|
|
||||||
funnymac.numeric_log OK
|
|
||||||
funnymac.numeric_vers OK
|
|
||||||
funnymac.tips OK
|
|
||||||
funnymac.truc OK
|
|
||||||
funnymac.vote OK
|
|
||||||
ghost_prod.accesstokens
|
|
||||||
note : Table does not support optimize, doing recreate + analyze instead
|
|
||||||
|
|
||||||
status : OK
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Réparer des tables :
|
|
||||||
|
|
||||||
[MySQL Server logs](https://dev.mysql.com/doc/refman/5.7/en/server-logs.html)
|
|
||||||
|
|
||||||
La 1ere chose à faire en cas de problèmes est de consulter les fichiers logs. Ceux-çi sont généralement avec les tables:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#osx (Homebrew):
|
|
||||||
|
|
||||||
$ cd /usr/local/var/mysql
|
|
||||||
total 388560
|
|
||||||
drwxr-xr-x 32 bruno admin 1024 28 nov 16:53 .
|
|
||||||
drwxrwxr-x 13 bruno admin 416 16 fév 2018 ..
|
|
||||||
-rw-rw---- 1 bruno admin 16384 28 nov 08:08 aria_log.00000001
|
|
||||||
-rw-rw---- 1 bruno admin 52 28 nov 08:08 aria_log_control
|
|
||||||
drwx------ 48 bruno admin 1536 1 déc 17:05 funnymac
|
|
||||||
drwx------ 53 bruno admin 1696 1 déc 17:05 ghost_prod
|
|
||||||
-rw-r----- 1 bruno admin 15114 28 nov 08:08 ib_buffer_pool
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 3 déc 07:19 ib_logfile0
|
|
||||||
-rw-rw---- 1 bruno admin 50331648 24 oct 12:51 ib_logfile1
|
|
||||||
-rw-rw---- 1 bruno admin 79691776 3 déc 07:19 ibdata1
|
|
||||||
-rw-rw---- 1 bruno admin 12582912 28 nov 16:53 ibtmp1
|
|
||||||
drwx------ 9 bruno admin 288 1 déc 17:05 mgpt
|
|
||||||
-rw-rw---- 1 bruno admin 0 24 jul 2017 multi-master.info
|
|
||||||
drwx------ 89 bruno admin 2848 1 déc 17:05 mysql
|
|
||||||
drwx------ 3 bruno admin 96 24 jul 2017 performance_schema
|
|
||||||
drwx------ 41 bruno admin 1312 1 déc 17:05 phpmyadmi
|
|
||||||
-rw-rw---- 1 bruno admin 1271878 3 déc 07:19 silverbook.home.err
|
|
||||||
-rw-rw---- 1 bruno admin 5 28 nov 16:53 silverbook.home.pid
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<u>Pour réparer, 2 solutions:</u>
|
|
||||||
|
|
||||||
**1) REPAIR TABLE:**
|
|
||||||
|
|
||||||
- ne nécessite pas l’arrêt de MySQL
|
|
||||||
- uniquement base MyISAM
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
|
||||||
MariaDB [zenphoto]> REPAIR TABLE _tags;
|
|
||||||
+----------------+--------+----------+---------------------------------------------------------+
|
|
||||||
| Table | Op | Msg_type | Msg_text |
|
|
||||||
+----------------+--------+----------+---------------------------------------------------------+
|
|
||||||
| zenphoto._tags | repair | note | The storage engine for the table doesn't support repair |
|
|
||||||
+----------------+--------+----------+---------------------------------------------------------+
|
|
||||||
|
|
||||||
1 row in set (0.006 sec)
|
|
||||||
```
|
|
||||||
|
|
||||||
Si l’erreur persiste, **vider le cache** (Flush all cache)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**2) mysqlcheck -r:**
|
|
||||||
|
|
||||||
- nécessite un arrêt du service MySQL
|
|
||||||
|
|
||||||
- uniquement base MyISAM
|
|
||||||
|
|
||||||
[MyISAM](https://dev.mysql.com/doc/refman/5.5/en/myisam-storage-engine.html):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysqlcheck -u root -ppassword -r zenphoto .comments
|
|
||||||
|
|
||||||
zenphoto..comments OK
|
|
||||||
```
|
|
||||||
|
|
||||||
[InnoDB](https://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysqlcheck -u root -ppassword -r zenphoto _tags
|
|
||||||
|
|
||||||
zenphoto._tags
|
|
||||||
|
|
||||||
note : The storage engine for the table doesn't support repair
|
|
||||||
```
|
|
||||||
|
|
||||||
Pour les tables InnoDB, il faut [forcer la récupération](https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html):
|
|
||||||
|
|
||||||
1) Arrêter **mysqld**:
|
|
||||||
|
|
||||||
2) Sauvegarder **mysql**:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#Linux
|
|
||||||
/var/lib/mysql/
|
|
||||||
|
|
||||||
#osx (Homebrew)
|
|
||||||
/usr/local/var/mysql/
|
|
||||||
```
|
|
||||||
|
|
||||||
3) Ajouter au fichier de configuration MySQL my.cnf:
|
|
||||||
|
|
||||||
```
|
|
||||||
#osx (Homebrew): /usr/local/etc/my.cnf
|
|
||||||
|
|
||||||
[mysqld]
|
|
||||||
innodb_force_recovery = 4
|
|
||||||
```
|
|
||||||
|
|
||||||
4) Redémarrer **mysqld**:
|
|
||||||
|
|
||||||
5a) Faire un dump des tables de la base avec **SELECT ... INTO OUTFILE**:
|
|
||||||
|
|
||||||
```mysql
|
|
||||||
MariaDB [zenphoto]> SELECT * FROM _tags INTO OUTFILE '/tmp/corrupted.txt';
|
|
||||||
Query OK, 170 rows affected (0.011 sec)
|
|
||||||
|
|
||||||
# Pour exporter au format csv:
|
|
||||||
MariaDB [zenphoto]> SELECT * FROM _tags INTO OUTFILE '/tmp/corrupted.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
|
|
||||||
Query OK, 170 rows affected (0.006 sec)
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
5b) Faire. un dump de toutes les tables:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysqldump -A -u root -ppassword > '/tmp/dump.sql';
|
|
||||||
```
|
|
||||||
|
|
||||||
6) Parfois cela peut suffire. Sinon,
|
|
||||||
|
|
||||||
7) Supprimer les tables / bases corrompues (DROP ...)
|
|
||||||
|
|
||||||
8) Arrêter **mysqld**:
|
|
||||||
|
|
||||||
9) Supprimer les ib*:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#Linux
|
|
||||||
/var/lib/mysql/ib*
|
|
||||||
|
|
||||||
#osx (Homebrew)
|
|
||||||
/usr/local/var/mysql/ib*
|
|
||||||
```
|
|
||||||
|
|
||||||
10) Quitter le mode force recovery:
|
|
||||||
|
|
||||||
```
|
|
||||||
[mysqld]
|
|
||||||
#innodb_force_recovery = 0
|
|
||||||
```
|
|
||||||
|
|
||||||
11) Redémarrer **mysqld**:
|
|
||||||
|
|
||||||
12) Restaurer les bases:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysql -u root -ppassword < dump.sql
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
https://www.nixpal.com/mysql-innodb-corruption-repair-guide/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Vérifier et réparer:
|
|
||||||
|
|
||||||
Vérifier toutes les bases et réparer les tables corrompues:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mysqlcheck -u root -p -A --auto-repair
|
|
||||||
|
|
||||||
Enter password:
|
|
||||||
|
|
||||||
funnymac.download OK
|
|
||||||
funnymac.downloads OK
|
|
||||||
…/…
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -557,7 +37,7 @@ funnymac.downloads OK
|
|||||||
|
|
||||||
Les commandes doivent se terminer par un **;**
|
Les commandes doivent se terminer par un **;**
|
||||||
|
|
||||||
```bash
|
```mysql
|
||||||
MariaDB [(none)]> mysqlcheck zenphoto
|
MariaDB [(none)]> mysqlcheck zenphoto
|
||||||
->
|
->
|
||||||
-> \c
|
-> \c
|
||||||
@@ -578,12 +58,6 @@ echo "0 4 * * Sun root mysqlcheck -u maintenance --optimize --all-databases" > /
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
252
docs/macos/webserver/php-fpm.md
Normal file
252
docs/macos/webserver/php-fpm.md
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
# Configurer PHP ([php-fpm](https://cwiki.apache.org/confluence/display/HTTPD/PHP-FPM))(Apache 2.4+):
|
||||||
|
|
||||||
|
#### php.ini
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /usr/local/etc/php/7.4/php.ini
|
||||||
|
$ nano /usr/local/etc/php/8.0/php.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /opt/homebrew/etc/php/7.4/php.ini
|
||||||
|
$ nano /opt/homebrew/etc/php/8.0/php.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Modifier le httpd.conf:
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /usr/local/etc/httpd/httpd.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /opt/homebrew/etc/httpd/httpd.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Dans *httpd.conf*, dé-commenter les lignes:
|
||||||
|
|
||||||
|
```http
|
||||||
|
LoadModule proxy_module libexec/mod_proxy.so
|
||||||
|
LoadModule proxy_fcgi_module libexec/mod_proxy_fcgi.so
|
||||||
|
LoadModule rewrite_module libexec/mod_rewrite.so
|
||||||
|
```
|
||||||
|
|
||||||
|
et supprimer / commenter les lignes `php_module`:
|
||||||
|
|
||||||
|
Mac intel:
|
||||||
|
|
||||||
|
```http
|
||||||
|
#LoadModule php7_module /usr/localopt/php@7.4/lib/httpd/modules/libphp7.so
|
||||||
|
#LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so
|
||||||
|
```
|
||||||
|
|
||||||
|
Mac M1:
|
||||||
|
|
||||||
|
```http
|
||||||
|
#LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so
|
||||||
|
#LoadModule php_module /opt/homebrew/opt/php@8.0/lib/httpd/modules/libphp.so
|
||||||
|
```
|
||||||
|
|
||||||
|
Puis:
|
||||||
|
|
||||||
|
mac intel, remplacer:
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.html
|
||||||
|
</IfModule>
|
||||||
|
```
|
||||||
|
|
||||||
|
par
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.php index.html
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<VirtualHost *:*>
|
||||||
|
ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/usr/local/var/www/$1"
|
||||||
|
</VirtualHost>
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
# 2.4.10+ can proxy to unix socket
|
||||||
|
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
|
||||||
|
# Else we can just use a tcp socket:
|
||||||
|
SetHandler "proxy:fcgi://127.0.0.1:9000"
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
|
mac M1, remplacer:
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.html
|
||||||
|
</IfModule>
|
||||||
|
```
|
||||||
|
|
||||||
|
par
|
||||||
|
|
||||||
|
```http
|
||||||
|
<IfModule dir_module>
|
||||||
|
DirectoryIndex index.php index.html
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<VirtualHost *:*>
|
||||||
|
ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/opt/homebrew/local/var/www/$1"
|
||||||
|
</VirtualHost>
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
# 2.4.10+ can proxy to unix socket
|
||||||
|
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
|
||||||
|
# Else we can just use a tcp socket:
|
||||||
|
SetHandler "proxy:fcgi://127.0.0.1:9000"
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Changer le port:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# mac M1
|
||||||
|
$ nano /opt/homebrew/etc/php/8.0/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
# mac intel
|
||||||
|
$ nano /usr/local/etc/php/8.0/php-fpm.d/www.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Remplacer
|
||||||
|
|
||||||
|
```ini
|
||||||
|
user = _www
|
||||||
|
group = _www
|
||||||
|
|
||||||
|
listen = 127.0.0.1:9000
|
||||||
|
```
|
||||||
|
|
||||||
|
par
|
||||||
|
|
||||||
|
```ini
|
||||||
|
user = bruno
|
||||||
|
group = staff
|
||||||
|
|
||||||
|
listen = 127.0.0.1:9080
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ nano /opt/homebrew/etc/httpd/httpd.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Remplacer
|
||||||
|
|
||||||
|
```http
|
||||||
|
<VirtualHost *:*>
|
||||||
|
ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/opt/homebrew/local/var/www/$1"
|
||||||
|
</VirtualHost>
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
# 2.4.10+ can proxy to unix socket
|
||||||
|
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
|
||||||
|
# Else we can just use a tcp socket:
|
||||||
|
SetHandler "proxy:fcgi://127.0.0.1:9000"
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
|
par
|
||||||
|
|
||||||
|
```http
|
||||||
|
<VirtualHost *:*>
|
||||||
|
ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9080/opt/homebrew/local/var/www/$1"
|
||||||
|
</VirtualHost>
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
# 2.4.10+ can proxy to unix socket
|
||||||
|
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
|
||||||
|
# Else we can just use a tcp socket:
|
||||||
|
SetHandler "proxy:fcgi://127.0.0.1:9080"
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Changer de version:
|
||||||
|
|
||||||
|
*PHP switcher script*:
|
||||||
|
|
||||||
|
`sphp.sh`
|
||||||
|
|
||||||
|
https://gist.github.com/rozsival/10289d1e2006c68009ace0478306ecd2
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
latest="8.0"
|
||||||
|
versions=("7.4" "8.1" "$latest")
|
||||||
|
valid=$(printf "|%s" "${versions[@]}")
|
||||||
|
switch="$1"
|
||||||
|
|
||||||
|
ERROR=$(tput setaf 1)
|
||||||
|
SUCCESS=$(tput setaf 2)
|
||||||
|
|
||||||
|
if [ -z "$switch" ]
|
||||||
|
then
|
||||||
|
echo "${ERROR}✖ PHP version required (${valid:1})"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! " ${versions[@]} " =~ " ${switch} " ]]
|
||||||
|
then
|
||||||
|
printf "${ERROR}✖ Invalid PHP version (valid: ${valid:1})"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "⇆ Switching PHP to version $switch\n\n"
|
||||||
|
|
||||||
|
php="php@$switch"
|
||||||
|
if [ "$switch" == "$latest" ] ; then php="php" ; fi
|
||||||
|
|
||||||
|
for v in ${versions[*]}
|
||||||
|
do
|
||||||
|
service="php@$v"
|
||||||
|
pattern="$service"
|
||||||
|
if [ "$v" == "$latest" ] ; then pattern="php[^@]" ; fi
|
||||||
|
status=$(brew services | grep "$pattern" | grep "started")
|
||||||
|
if [ ! -z "$status" ] ; then brew services stop "$service" ; fi
|
||||||
|
brew unlink "$service"
|
||||||
|
done
|
||||||
|
|
||||||
|
brew link --overwrite --force "$php"
|
||||||
|
brew services start "$php"
|
||||||
|
|
||||||
|
printf "\n${SUCCESS}✔ PHP switched to version $switch"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Installation Mac intel:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Dans /usr/local/bin/sphp
|
||||||
|
|
||||||
|
$ chmod +x /usr/local/bin/sphp
|
||||||
|
```
|
||||||
|
|
||||||
|
Installation Mac M1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /opt/homebrew/bin/sphp
|
||||||
|
|
||||||
|
$ chmod +x /opt/homebrew/bin/sphp
|
||||||
|
```
|
||||||
|
|
||||||
|
Utilisation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sphp 7.4
|
||||||
|
```
|
||||||
|
|
||||||
|
https://kevdees.com/macos-11-big-sur-nginx-setup-multiple-php-versions/
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
# Installer PHP (homebrew)
|
# php
|
||||||
|
|
||||||
### Installation:
|
|
||||||
|
|
||||||
|
### Installer PHP (homebrew)
|
||||||
|
|
||||||
|
#### Installation:
|
||||||
|
|
||||||
Ajouter le tap:
|
Ajouter le tap:
|
||||||
|
|
||||||
@@ -12,112 +16,36 @@ $ brew update
|
|||||||
Installer différentes versions de PHP:
|
Installer différentes versions de PHP:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ brew install shivammathur/php/php@7.4
|
$ brew install shivammathur/php/php@7.4 # installe également la formule php@7.4
|
||||||
$ brew link --overwrite --force php@7.4
|
$ brew link --overwrite --force php@7.4
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ brew install shivammathur/php/php@8.0
|
$ brew install shivammathur/php/php # installe également la formule php (8.0)
|
||||||
$ brew link --overwrite --force php@8.0
|
$ brew link --overwrite --force php
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Configurer PHP:
|
### Configurer php sous serveur Apache:
|
||||||
|
|
||||||
Mac intel:
|
1. [mod-php](mod-php.md)
|
||||||
|
|
||||||
|
2. [php-fpm](php-fpm.md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Redémarrer PHP:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ nano /usr/local/etc/php/7.4/php.ini
|
brew services restart shivammathur/php/php # php 8.0
|
||||||
$ nano /usr/local/etc/php/8.0/php.ini
|
brew services restart shivammathur/php/php@7.4
|
||||||
```
|
brew services restart shivammathur/php/php@8.1
|
||||||
|
|
||||||
Mac M1:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ nano /opt/homebrew/etc/php/7.4/php.ini
|
|
||||||
$ nano /opt/homebrew/etc/php/8.0/php.ini
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```ini
|
### Redémarrer le serveur web:
|
||||||
[Date]
|
|
||||||
; Defines the default timezone used by the date functions
|
|
||||||
; http://php.net/date.timezone
|
|
||||||
date.timezone = Europe/Paris
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; Error handling and logging ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
error_log = php_errors.log
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
; Resource Limits ;
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
memory_limit = 512M
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Modifier le httpd.conf:
|
|
||||||
|
|
||||||
Mac intel:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ nano /usr/local/etc/httpd/httpd.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
Mac M1:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ nano /opt/homebrew/etc/httpd/httpd.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
Dans *httpd.conf*, ajouter les lignes:
|
|
||||||
|
|
||||||
Mac intel:
|
|
||||||
|
|
||||||
```http
|
|
||||||
LoadModule php7_module /usr/localopt/php@7.4/lib/httpd/modules/libphp7.so
|
|
||||||
#LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so
|
|
||||||
```
|
|
||||||
|
|
||||||
Mac M1:
|
|
||||||
|
|
||||||
```http
|
|
||||||
LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so
|
|
||||||
#LoadModule php_module /opt/homebrew/opt/php@8.0/lib/httpd/modules/libphp.so
|
|
||||||
```
|
|
||||||
|
|
||||||
intel / M1:
|
|
||||||
|
|
||||||
Remplacer:
|
|
||||||
|
|
||||||
```http
|
|
||||||
<IfModule dir_module>
|
|
||||||
DirectoryIndex index.html
|
|
||||||
</IfModule>
|
|
||||||
```
|
|
||||||
|
|
||||||
par
|
|
||||||
|
|
||||||
```http
|
|
||||||
<IfModule dir_module>
|
|
||||||
DirectoryIndex index.php index.html
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
<FilesMatch \.php$>
|
|
||||||
SetHandler application/x-httpd-php
|
|
||||||
</FilesMatch>
|
|
||||||
```
|
|
||||||
|
|
||||||
Redémarrer le serveur web:
|
|
||||||
|
|
||||||
- pour Apache (httpd): `brew services restart httpd`
|
- pour Apache (httpd): `brew services restart httpd`
|
||||||
- pour Nginx: `brew services restart nginx`
|
- pour Nginx: `brew services restart nginx`
|
||||||
@@ -130,45 +58,14 @@ echo "<?php phpinfo();" > ~/Sites/info.php
|
|||||||
|
|
||||||
et aller sur http://localhost/info.php
|
et aller sur http://localhost/info.php
|
||||||
|
|
||||||
|
- mod-php: `Server API: Apache 2.0 Handler`
|
||||||
|
- php-fpm: `Server API: FPM/FastCGI`
|
||||||
|
|
||||||
Si PHP n'est pas interprété, redémarrer le mac.
|
Si PHP n'est pas interprété, redémarrer le mac.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Changer de version:
|
### Version de PHP:
|
||||||
|
|
||||||
#### Méthode 1:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ brew unlink php && brew link --overwrite --force php@7.4
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Méthode 2:
|
|
||||||
|
|
||||||
*PHP switcher script*
|
|
||||||
|
|
||||||
Installation Mac intel:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp
|
|
||||||
$ chmod +x /usr/local/bin/sphp
|
|
||||||
```
|
|
||||||
|
|
||||||
Installation Mac M1:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ curl -L https://raw.githubusercontent.com/vadimbk/sphp/main/sphp > /opt/homebrew/bin/sphp
|
|
||||||
$ chmod +x /opt/homebrew/bin/sphp
|
|
||||||
```
|
|
||||||
|
|
||||||
Utilisation:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ sphp 7.4
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Version de PHP:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ php -v
|
$ php -v
|
||||||
@@ -187,7 +84,7 @@ $ php -i
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Logs:
|
### Logs:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/opt/homebrew/var/log/php-fpm.log
|
/opt/homebrew/var/log/php-fpm.log
|
||||||
@@ -232,7 +129,8 @@ xdebug.mode=debug
|
|||||||
$ brew install apcu@8.0
|
$ brew install apcu@8.0
|
||||||
|
|
||||||
# Fichier config
|
# Fichier config
|
||||||
/opt/homebrew/etc/php/8.0/conf.d/apcu.ini
|
/opt/homebrew/etc/php/8.0/conf.d/apcu.ini # M1
|
||||||
|
/usr/local/etc/php/8.0/conf.d/apcu.ini # intel
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -254,7 +152,8 @@ apc.enable_cli=1
|
|||||||
$ brew install imagick@8.0
|
$ brew install imagick@8.0
|
||||||
|
|
||||||
# Fichier config
|
# Fichier config
|
||||||
/opt/homebrew/etc/php/8.0/conf.d/imagick.ini
|
/opt/homebrew/etc/php/8.0/conf.d/imagick.ini # M1
|
||||||
|
/usr/local/etc/php/8.0/conf.d/imagick.ini # intel
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -272,7 +171,8 @@ extension="/opt/homebrew/opt/imagick@8.0/imagick.so"
|
|||||||
$ brew install memcached@8.0
|
$ brew install memcached@8.0
|
||||||
|
|
||||||
# Fichier config
|
# Fichier config
|
||||||
/opt/homebrew/etc/php/7.4/conf.d/memcached.ini
|
/opt/homebrew/etc/php/7.4/conf.d/memcached.ini # M1
|
||||||
|
/usr/local/etc/php/8.0/conf.d/memcached.ini # intel
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
16
mkdocs.yml
16
mkdocs.yml
@@ -11,6 +11,7 @@ nav:
|
|||||||
- Linux:
|
- Linux:
|
||||||
- Index: Linux/index.md
|
- Index: Linux/index.md
|
||||||
- ack: Linux/ack.md
|
- ack: Linux/ack.md
|
||||||
|
- Alternatives: Linux/alternatives.md
|
||||||
- Apps:
|
- Apps:
|
||||||
- AppImage: Linux/Apps/AppImage.md
|
- AppImage: Linux/Apps/AppImage.md
|
||||||
- flatpak: Linux/Apps/flatpak.md
|
- flatpak: Linux/Apps/flatpak.md
|
||||||
@@ -30,12 +31,14 @@ nav:
|
|||||||
- index: Linux/Editeurs/index.md
|
- index: Linux/Editeurs/index.md
|
||||||
- nano: Linux/Editeurs/nano.md
|
- nano: Linux/Editeurs/nano.md
|
||||||
- vi: Linux/Editeurs/vi.md
|
- vi: Linux/Editeurs/vi.md
|
||||||
|
- Exa: Linux/exa.md
|
||||||
- Executer: Linux/executer.md
|
- Executer: Linux/executer.md
|
||||||
- fd (find): Linux/fd.md
|
- fd (find): Linux/fd.md
|
||||||
- Filtres: Linux/filtres.md
|
- Filtres: Linux/filtres.md
|
||||||
- Format ext4: Linux/format_ext4.md
|
- Format ext4: Linux/format_ext4.md
|
||||||
- find: Linux/find.md
|
- find: Linux/find.md
|
||||||
- for: Linux/for.md
|
- for: Linux/for.md
|
||||||
|
- fzf: Linux/fzf.md
|
||||||
- grep: Linux/grep.md
|
- grep: Linux/grep.md
|
||||||
- grep --options (fr): Linux/grep-options-fr.md
|
- grep --options (fr): Linux/grep-options-fr.md
|
||||||
- grep --options (us): Linux/grep-options.md
|
- grep --options (us): Linux/grep-options.md
|
||||||
@@ -107,6 +110,8 @@ nav:
|
|||||||
- Conda: macos/python/conda.md
|
- Conda: macos/python/conda.md
|
||||||
- Django: macos/python/Django.md
|
- Django: macos/python/Django.md
|
||||||
- pip: macos/python/pip.md
|
- pip: macos/python/pip.md
|
||||||
|
- pipx: macos/python/pipx.md
|
||||||
|
- poetry: macos/python/poetry.md
|
||||||
- Python 3: macos/python/python3.md
|
- Python 3: macos/python/python3.md
|
||||||
- Environnement virtuel: macos/python/virtuel.md
|
- Environnement virtuel: macos/python/virtuel.md
|
||||||
- Ruby: macos/ruby.md
|
- Ruby: macos/ruby.md
|
||||||
@@ -128,6 +133,7 @@ nav:
|
|||||||
- WebServer:
|
- WebServer:
|
||||||
- Index: macos/webserver/index.md
|
- Index: macos/webserver/index.md
|
||||||
- Apache: macos/webserver/apache.md
|
- Apache: macos/webserver/apache.md
|
||||||
|
- Apache (M1): macos/webserver/apache_M1.md
|
||||||
- Composer: macos/webserver/composer.md
|
- Composer: macos/webserver/composer.md
|
||||||
- erreurs: macos/webserver/errors_apache.md
|
- erreurs: macos/webserver/errors_apache.md
|
||||||
- htpasswd: macos/webserver/htpasswd.md
|
- htpasswd: macos/webserver/htpasswd.md
|
||||||
@@ -135,6 +141,7 @@ nav:
|
|||||||
- MySQL (installation): macos/webserver/install_mysql.md
|
- MySQL (installation): macos/webserver/install_mysql.md
|
||||||
- MySQL (trucs): macos/webserver/mysql.md
|
- MySQL (trucs): macos/webserver/mysql.md
|
||||||
- PHP: macos/webserver/php.md
|
- PHP: macos/webserver/php.md
|
||||||
|
- PHP 7.1: macos/webserver/php71.md
|
||||||
- PHP 7.3: macos/webserver/php73.md
|
- PHP 7.3: macos/webserver/php73.md
|
||||||
- PHP 7.4: macos/webserver/php74.md
|
- PHP 7.4: macos/webserver/php74.md
|
||||||
- PHP 8.0: macos/webserver/php80.md
|
- PHP 8.0: macos/webserver/php80.md
|
||||||
@@ -153,6 +160,7 @@ nav:
|
|||||||
- Ghost: Plesk/Ghost.md
|
- Ghost: Plesk/Ghost.md
|
||||||
- Git: Plesk/git.md
|
- Git: Plesk/git.md
|
||||||
- Gitea: Plesk/Gitea.md
|
- Gitea: Plesk/Gitea.md
|
||||||
|
- Joplin: Plesk/joplin.md
|
||||||
- Nextcloud: Plesk/nextcloud.md
|
- Nextcloud: Plesk/nextcloud.md
|
||||||
- Programmation:
|
- Programmation:
|
||||||
-Python:
|
-Python:
|
||||||
@@ -216,6 +224,7 @@ nav:
|
|||||||
- Python 3: Synology/dsm6/python.md
|
- Python 3: Synology/dsm6/python.md
|
||||||
- Services: Synology/dsm6/services.md
|
- Services: Synology/dsm6/services.md
|
||||||
- DSM 7:
|
- DSM 7:
|
||||||
|
- Apache: Synology/dsm7/apache.md
|
||||||
- DSM 7: Synology/dsm7/dsm7.md
|
- DSM 7: Synology/dsm7/dsm7.md
|
||||||
- Node: Synology/dsm7/node.md
|
- Node: Synology/dsm7/node.md
|
||||||
- Python 3: Synology/dsm7/python.md
|
- Python 3: Synology/dsm7/python.md
|
||||||
@@ -245,11 +254,13 @@ nav:
|
|||||||
- Trucs: Windows/PowerShell/trucs.md
|
- Trucs: Windows/PowerShell/trucs.md
|
||||||
- systeminfo: Windows/systeminfo.md
|
- systeminfo: Windows/systeminfo.md
|
||||||
- Windows Terminal: Windows/Terminal.md
|
- Windows Terminal: Windows/Terminal.md
|
||||||
|
- winget: Windows/winget.md
|
||||||
- Installer WSL: Windows/wsl.md
|
- Installer WSL: Windows/wsl.md
|
||||||
- Personnaliser WSL: Windows/wsl_2.md
|
- Personnaliser WSL: Windows/wsl_2.md
|
||||||
- Divers:
|
- Divers:
|
||||||
- Index: Divers/index.md
|
- Index: Divers/index.md
|
||||||
- Adobe: Divers/adobe.md
|
- Adobe: Divers/adobe.md
|
||||||
|
- Alfred: Divers/alfred.md
|
||||||
- bash:
|
- bash:
|
||||||
- basename: Divers/bash/basename.md
|
- basename: Divers/bash/basename.md
|
||||||
- Commandes: Divers/bash/commandes.md
|
- Commandes: Divers/bash/commandes.md
|
||||||
@@ -263,9 +274,11 @@ nav:
|
|||||||
- Commades DOS (2): Divers/batch/Commandes_DOS_2.md
|
- Commades DOS (2): Divers/batch/Commandes_DOS_2.md
|
||||||
- Changer de shell: Divers/Changer_shell.md
|
- Changer de shell: Divers/Changer_shell.md
|
||||||
- Chromium: Divers/Chromium.md
|
- Chromium: Divers/Chromium.md
|
||||||
|
- diraction: Divers/diraction.md
|
||||||
- Docker:
|
- Docker:
|
||||||
- docker: Divers/docker/docker.md
|
- docker: Divers/docker/docker.md
|
||||||
- applications: Divers/docker/applications.md
|
- applications: Divers/docker/applications.md
|
||||||
|
- dotbare: Divers/dotbare.md
|
||||||
- git:
|
- git:
|
||||||
- Index: Divers/git/index.md
|
- Index: Divers/git/index.md
|
||||||
- git: Divers/git/git.md
|
- git: Divers/git/git.md
|
||||||
@@ -288,6 +301,7 @@ nav:
|
|||||||
- Alexa: Divers/Sonos/alexa.md
|
- Alexa: Divers/Sonos/alexa.md
|
||||||
- myMedia for Alexa: Divers/Sonos/myMedia.md
|
- myMedia for Alexa: Divers/Sonos/myMedia.md
|
||||||
- soco-cli: Divers/Sonos/soco-cli.md
|
- soco-cli: Divers/Sonos/soco-cli.md
|
||||||
|
- tmux: Divers/tmux.md
|
||||||
- Vagrant:
|
- Vagrant:
|
||||||
- Installation: Divers/Vagrant/Vagrant.md
|
- Installation: Divers/Vagrant/Vagrant.md
|
||||||
- Créer une Vagrant box: Divers/Vagrant/creer_une_vagrant_box.md
|
- Créer une Vagrant box: Divers/Vagrant/creer_une_vagrant_box.md
|
||||||
@@ -318,6 +332,8 @@ nav:
|
|||||||
- OVH: Divers/wp-cli/ovh.md
|
- OVH: Divers/wp-cli/ovh.md
|
||||||
- zsh:
|
- zsh:
|
||||||
- Antibody: Divers/zsh/antibody.md
|
- Antibody: Divers/zsh/antibody.md
|
||||||
|
- Plugins: Divers/zsh/plugins.md
|
||||||
|
- zinit: Divers/zsh/zinit.md
|
||||||
- zsh: Divers/zsh/zsh.md
|
- zsh: Divers/zsh/zsh.md
|
||||||
- zsh2: Divers/zsh/zsh2.md
|
- zsh2: Divers/zsh/zsh2.md
|
||||||
- MkDocs: mkdocs.md
|
- MkDocs: mkdocs.md
|
||||||
|
|||||||
Reference in New Issue
Block a user