Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
linux:mysql [17-10-2017 10:19] edmc73 |
linux:mysql [15-07-2019 09:21] edmc73 [Quelques commandes] |
||
---|---|---|---|
Ligne 15: | Ligne 15: | ||
* http:// | * http:// | ||
* https:// | * https:// | ||
- | * http:// | + | * http:// |
+ | |||
+ | |||
+ | A voir le paquet **php5-mysqlnd** qui est un client mysql natif qui est optimisé par mysql pour mysql | ||
Ligne 24: | Ligne 27: | ||
mysql> show variables; | mysql> show variables; | ||
mysql> show global variables like ' | mysql> show global variables like ' | ||
+ | |||
+ | Pour modifier une variable global | ||
+ | mysql> set global max_connections=500; | ||
Pour voir les status | Pour voir les status | ||
Ligne 33: | Ligne 39: | ||
mysqld --verbose --help | head | mysqld --verbose --help | head | ||
| | ||
- | | + | |
+ | |||
+ | Process list | ||
+ | mysql> | ||
+ | Kill process | ||
+ | mysql> | ||
+ | |||
+ | |||
+ | ==== Sauvegarder ==== | ||
Sauvegarder une base | Sauvegarder une base | ||
mysqldump -u user -p nom_de_la_base > backup.sql | mysqldump -u user -p nom_de_la_base > backup.sql | ||
Ligne 43: | Ligne 57: | ||
mysql -u user -p nom_de_la_base < backup.sql | mysql -u user -p nom_de_la_base < backup.sql | ||
- | Process list | ||
- | mysql> | ||
- | Kill process | ||
- | mysql> | ||
+ | Script PERL pour extraire une table d'un dump SQL | ||
+ | <code perl> | ||
+ | # | ||
+ | #extract a single table from a mysql dump | ||
+ | BEGIN { | ||
+ | $table or warn | ||
+ | " | ||
+ | and exit 1; | ||
+ | } | ||
+ | |||
+ | /^DROP TABLE IF EXISTS `$table`/ .. /^UNLOCK TABLES;$/ and print; | ||
+ | </ | ||
===== Logguer les requêtes en temps réel ponctuellement ===== | ===== Logguer les requêtes en temps réel ponctuellement ===== | ||
Ligne 111: | Ligne 133: | ||
Plein d' | Plein d' | ||
+ | |||
+ | Un autre script dans les paquets **automysqlbackup** https:// | ||
+ | |||
===== Percona XtraBackup ===== | ===== Percona XtraBackup ===== | ||
Ligne 166: | Ligne 191: | ||
</ | </ | ||
+ | |||
+ | ===== InnoDB ===== | ||
+ | |||
+ | Une requête intégressante | ||
+ | SHOW ENGINE INNODB STATUS | ||
+ | | ||
+ | |||
+ | ===== Partition ===== | ||
+ | |||
+ | Sur le lien ci-dessous, des scripts permettant d' | ||
+ | |||
+ | => http:// | ||
+ | |||
+ | ===== Erreur ===== | ||
+ | |||
+ | Après avoir lancé une optimization puis violemment killé la requete en cours, la table était inaccessible ... | ||
+ | |||
+ | < | ||
+ | Starting MySQL database server: mysqld. | ||
+ | Checking for corrupt, not cleanly closed and upgrade needing tables.. | ||
+ | ERROR 144 (HY000) at line 1: Table ' | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # myisamchk dashboard_log | ||
+ | Checking MyISAM file: dashboard_log | ||
+ | Data records: | ||
+ | myisamchk: warning: Table is marked as crashed and last repair failed | ||
+ | - check file-size | ||
+ | myisamchk: warning: Size of indexfile is: 275469312 | ||
+ | - check record delete-chain | ||
+ | - check key delete-chain | ||
+ | - check index reference | ||
+ | - check data record references index: 1 | ||
+ | - check data record references index: 2 | ||
+ | - check data record references index: 3 | ||
+ | - check record links | ||
+ | myisamchk: error: Record-count is not ok; is 5773841 | ||
+ | myisamchk: warning: Found 484145612 deleted space. | ||
+ | myisamchk: warning: Found 1581466 deleted blocks | ||
+ | myisamchk: warning: Found 8799790 key parts. Should be: 654724 | ||
+ | MyISAM-table ' | ||
+ | Fix it using switch " | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # myisamchk -r -v dashboard_log | ||
+ | - recovering (with sort) MyISAM-table ' | ||
+ | Data records: 654724 | ||
+ | - Fixing index 1 | ||
+ | - Searching for keys, allocating buffer for 147793 keys | ||
+ | - Merging 5773841 keys | ||
+ | - Last merge and dumping keys | ||
+ | - Fixing index 2 | ||
+ | - Searching for keys, allocating buffer for 139720 keys | ||
+ | - Merging 5773841 keys | ||
+ | - Last merge and dumping keys | ||
+ | - Fixing index 3 | ||
+ | - Searching for keys, allocating buffer for 2604 keys | ||
+ | - Merging 5773841 keys | ||
+ | - Last merge and dumping keys | ||
+ | Data records: 5773841 | ||
+ | </ | ||
+ | |||
+ | Ça remarche ! et même à chaud sans redémarrer mysql ! J'ai même l' | ||