User Tools

Site Tools


linux:scribble

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
linux:scribble [2017/05/16 18:34]
stybla add tricks for Jenkins
linux:scribble [2018/07/27 06:54] (current)
stybla How to change encoding of MySQL DB and tables
Line 301: Line 301:
  
 Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/​dm-crypt. Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/​dm-crypt.
 +
 +===== MySQL =====
 +
 +==== Convert database to UTF-8 encoding ====
 +
 +Originally found at [[https://​www.a2hosting.com/​kb/​developer-corner/​mysql/​convert-mysql-database-utf-8|a2hosting.com]]
 +
 +Run mysql and check the encoding:
 +
 +<​code>​
 +SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "​DBNAME";​
 +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 = "​DBNAME"​ AND T.table_name = "​TABLENAME";​
 +</​code>​
 +
 +Change encoding of tables:
 +
 +<​code>​
 +cat > ~/.my.cnf <<EOF
 +[client]
 +user=USER
 +password=PASSWORD
 +EOF
 +mysql --database=DBNAME -B -N -e "SHOW TABLES"​ | awk '​{print "SET foreign_key_checks = 0; ALTER TABLE",​ $1, "​CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;​ SET foreign_key_checks = 1; "​}'​ | mysql --database=DBNAME
 +</​code>​
 +
 +Change encoding of DB itself:
 +<​code>​
 +ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;​
 +</​code>​
 +
 +Remove ''​~/​.my.cnf''​ or edit out username and password.
 +
  
 ===== OpenOffice/​LibreOffice ===== ===== OpenOffice/​LibreOffice =====
linux/scribble.txt · Last modified: 2018/07/27 06:54 by stybla