User Tools

Site Tools


doc:appunti:linux:sa:mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
doc:appunti:linux:sa:mysql [2019/11/11 11:10] – [Riparazione di tabelle corrotte] niccolodoc:appunti:linux:sa:mysql [2021/01/15 10:38] – [Encoding del database e delle tabelle] niccolo
Line 336: Line 336:
   * **tables_priv** Table-level privileges.   * **tables_priv** Table-level privileges.
   * **columns_priv** Column-level privileges.   * **columns_priv** Column-level privileges.
-  * **procs_priv** Stored procedure and function privileges. +  * **procs_priv** Stored procedure and function privileges. 
 + 
 +===== Encoding del database e delle tabelle ===== 
 + 
 +Pare che ancora nel 2020 MySQL (MariaDB 10.3) crei le tabelle con encoding **Latin1**. Ecco come verificare l'encoding del database e di una tabella: 
 + 
 +<code> 
 +SELECT default_character_set_name FROM information_schema.SCHEMATA 
 +    WHERE schema_name = 'database_name'; 
 + 
 ++----------------------------+ 
 +| default_character_set_name | 
 ++----------------------------+ 
 +| utf8mb4                    | 
 ++----------------------------+ 
 +</code> 
 + 
 +<code> 
 +SELECT CCSA.character_set_name FROM information_schema.TABLES T, 
 +    information_schema.COLLATION_CHARACTER_SET_APPLICABILITY CCSA 
 +    WHERE CCSA.collation_name = T.table_collation AND T.table_schema = 'database_name' 
 +    AND T.table_name = 'table_name'; 
 + 
 ++--------------------+ 
 +| character_set_name | 
 ++--------------------+ 
 +| latin1             | 
 ++--------------------+ 
 +</code> 
 + 
 +===== Errore "Tablespace is missing for a table" ===== 
 + 
 +Può capitare con l'engine InnoDB che il file contenente una tabella sparisca (errore sul filesystem, mancato restore, ecc.). In tal caso nella directory **/var/lib/mysql/dbname/** si può trovare il file **tablename.frm** ma manca il relativo **tablename.idb**. 
 + 
 +Ovviamente i dati contenuti nella tabella sono persi, ma dovrebbe essere possibile ricostruire la struttura dal file **frm**. Nella pagina **[[https://medium.com/@badalnaik/mariadb-mysql-restore-database-from-frm-and-ibd-files-6ea95269fba2|MariaDB/MySQL — Restore Database From .frm And .ibd Files]]** c'è una ricetta che però richiede il tool **mysqlfrm**. Si tratta di uno script Python che veniva distribuito con il pacchetto **mysql-utilities** ma solo nella vecchia **Debian 9 Stretch**. 
doc/appunti/linux/sa/mysql.txt · Last modified: 2023/03/27 11:31 by niccolo