Hi all,
I'd toyed with my MySQL encoding for over two hours because I thought I had a MySQL encoding problem... Turns out it was another problem (this message was altered substantially since it was first posted).
I couldn't figure out how to delete a post, then decided to conserve some of the info given that I learned a lot nevertheless. Also because I thought others could learn from this, and there remain a few problems and unanswered questions nevertheless.
This was my MySQL encoding:
Code:
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
I then altered my my.cnf file adding the "default-character-set = utf" to all three sections of the file, i.e. [client], [mysql] and [mysqld], deleted the database, restarted mysqld, recreated the database and used my script to recreate new tables and populate the newly created database (I read this article:
http://www.bluebox.net/news/2009/07/mysql_encoding/).
I got utf8 when I ran the above command:
Code:
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
The problem persisted, so I tried yet other potential solutions... And, I still get a problem when I restart MySQL, which I don't know how to solve (yes, I did try what was suggested in the message below).
Code:
$ mysqld restart
121003 21:32:11 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
Incidentally, I also get the following regardless of the my.cnf (the original or the altered version):
Code:
$ mysqld restart
...
121003 21:32:11 [Warning] Can't create test file /var/lib/mysql/user-laptop.lower-test
121003 21:32:11 [Warning] Can't create test file /var/lib/mysql/user-laptop.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
121003 21:32:11 [ERROR] Aborting
121003 21:32:11 [Note] mysqld: Shutdown complete
I added the following at the beginning of my MySQL script (overkill I know, but I originally thought I had a MySQL encoding problem... I'm conserving all of this because it is useful nevertheless):
Code:
SET names utf8;
SET global character_set_client = utf8;
SET global character_set_connection = utf8;
SET global character_set_database = utf8;
SET global character_set_results = utf8;
SET global character_set_server = utf8;
Here's another useful (but perhaps dated) link suggesting more my.cnf file additions than the previous one (
http://stackoverflow.com/questions/3...f8-in-my-cnf):
Code:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
default-character-set = utf8
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
So my problem was a parsing problem going from one file to another and not a MySQL encoding problem.
But the question remains, how does one go about getting rid of the error messages when restarting MySQL? Also, and perhaps this will fix the error message problem, what is the proper way to alter the my.cnf for exclusively utf-8 encoding?
Thanks,
rm