/etc/mysql/my.cnf:
innodb_file_per_table
Dump all databases by calling:
/usr/bin/mysqldump --extended-insert --all-databases --add-drop-database --disable-keys --flush-privileges --quick --routines --triggers > all-databases.sql
Stop the MySQL server;
Rename or remove (in case you’ve already backed it up) the MySQL data directory and create an empty one with the same name and permissions;
Make the appropriate changes in my.cnf;
Re-initialize the database with the following command (replace the ‘mysqld‘ with the login of the user your MySQL server runs as) (10x, Påven):
sudo -u mysqld mysql_install_db
Start the MySQL server;
Get into the ‘mysql‘ console and type:
SET FOREIGN_KEY_CHECKS=0;
SOURCE all-databases.sql;
SET FOREIGN_KEY_CHECKS=1;
Restart the MySQL server. (10x, czaby)
At this point everything should be fine and you can test it by starting again the services that use MySQL.
wp-config.php:
define('DB_CHARSET', 'utf8');
.bashrc:
mygrants()
{
mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}
mygrants --host=prod-db1 --user=admin --password=secret | grep rails_admin | mysql --host=staging-db1 --user=admin --password=secret
mygrants --password=xxx> /mysql.grant
GRANT ALL PRIVILEGES ON `database_%` . * TO 'user'@'localhost' WITH GRANT OPTION ;
$ mysqldump -u root -p dbname >~/db_name.sql
$ mysql -u root -pmypassword
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 812
Server version: 5.1.20-beta-log FreeBSD port: mysql-server-5.1.20
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql> create database dbname_copy
mysql> use dbname_copy
mysql> source ~/db_name.sql
mysqldump -u root -p --all-databases > backup092210.sql
$ mysqldump –default-character-set=latin1 –databases wordpress > m.sql
$ replace “CHARSET=latin1″ “CHARSET=utf8″ \
“SET NAMES latin1″ “SET NAMES utf8″ < m.sql > m2.sql
$ mysql < m2.sql
wp-config.php:
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ”);
atppp’s Blog » Convert WordPress database from Latin1 to UTF-8