LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2012, 02:55 PM   #1
rm_-rf_windows
Member
 
Registered: Jun 2007
Location: Europe
Distribution: Ubuntu
Posts: 292

Rep: Reputation: 27
Editing the MySQL my.cnf file for exclusively utf-8 encoding


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

Last edited by rm_-rf_windows; 10-03-2012 at 03:26 PM. Reason: Problem was not a MySQL problem, but a parsing problem (file to file)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chinese encoding not encoding in kate linuxmandrake Linux - Software 1 12-12-2010 08:50 AM
MySQL encoding problems (HELP HELP HELP!) tulane Linux - Software 7 04-19-2010 01:18 AM
MySQL 5 installation nightmare nr0mx Linux - Software 3 07-14-2009 08:49 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration