Mot-clé - mysql

Fil des billets - Fil des commentaires

[ERROR] Failed to open the relay log [ERROR] Could not find target log during relay log initialization [ERROR] Initialized Master_info from [ERROR] Failed to create a new master info file [ERROR] Failed to initialize multi master structures - Aborting

Visiblement, suite à changement de configuration réseau DHCP et nom d'hôte, impossible de lancer le serveur MySQL MariaDB.

Puisque je n'avais pas besoin de la réplication,

en modifiant, le my.ini, et rajoutant :

slave_sql_verify_checksum = OFF

et supprimant : master-xxx.info mysql-relay-xxx.index relay-log-xxx.info

le serveur se relance :

Lire la suite

[ERROR] mysqld.exe: Index for table '.\mysql\db' is corrupt; try to repair it Couldn't repair table: mysql.db

Aie ! C'est le drame, MySQL / MariaDB ne se lance plus sous mon installation XAMPP, et le fichier de log (mysql\data\mysql_error.log), indique :

[ERROR] mysqld.exe: Table '.\mysql\db' is marked as crashed and should be repaired
[ERROR] mysqld.exe: Index for table '.\mysql\db' is corrupt; try to repair it
[ERROR] Couldn't repair table: mysql.db
[ERROR] Fatal error: Can't open and lock privilege tables: Index for table 'db' is corrupt; try to repair it

Lire la suite

SQL "matching found rows" vs "affected rows"

Lors de modifications (UPDATE, DELETE) comment différencier le nombre d'enregistrement qui matche au critère WHERE et le nombre d'enregistrement réellement modifiés par la requête ?

  • "found (matched) rows" le nombre d'enregistrements trouvés (potentiellement modifiable)
  • "affected (changed) rows" le nombre d'enregistrements véritablement changés parmi les trouvés

Lire la suite

sql occurence char count

Comment compter le nombre d’occurrence d'un caractère dans une colonne ?

SET @string = "Bonjour ""Mr Vinal""; il fait beau l'été, l'automne et l'hivers, n'est ce pas ?";
SELECT 
SUM( LENGTH(@string ) ) AS total_length,
SUM( LENGTH(@string) - LENGTH(replace(@string, ',', '')) ) AS coma_virgule, 
SUM( LENGTH(@string) - LENGTH(replace(@string, '''', '')) ) AS quote_cote, 
SUM( LENGTH(@string) - LENGTH(replace(@string, '"', '')) ) AS double_quote_cote, 
SUM( LENGTH(@string) - LENGTH(replace(@string, ';', '')) ) AS semicolon_point_virgule
;
/*
+--------------+--------------+------------+-------------------+-------------------------+
| total_length | coma_virgule | quote_cote | double_quote_cote | semicolon_point_virgule |
+--------------+--------------+------------+-------------------+-------------------------+
|           79 |            2 |          4 |                 2 |                       1 |
+--------------+--------------+------------+-------------------+-------------------------+
*/

Lire la suite

Deadlock MySQL

Exception : Deadlock found when trying to get lock; try restarting transaction com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction

Exception::getMessage: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

Lire la suite