Mysql character set
26 januari 2007
Today I had this problem with a MySQL/php application:
Illegal mix of collations (latin1_bin,IMPLICIT) and (latin1_swedish_ci,IMPLICIT)
I’ve created this loop to solve the problem, because the server contains several database with lots of tables:
-
passwd="yeah right!"
-
mysql="mysql -u root -p"$passwd" -ss -B -e"
-
$mysql "show databases"|while read db; do
-
$mysql "SHOW TABLES FROM $db"|while read table; do
-
if [ "$($mysql "show create table $db.$table"|grep -c latin1_bin)" != "0" ]; then
-
$mysql "ALTER TABLE $db.$table CONVERT TO CHARACTER SET latin1"
-
fi
-
done
-
done
Categorieën:Linux Tips & Trics