Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.7Mb
PDF (A4) - 37.7Mb
PDF (RPM) - 33.8Mb
HTML Download (TGZ) - 8.4Mb
HTML Download (Zip) - 8.4Mb
HTML Download (RPM) - 7.3Mb
Man Pages (TGZ) - 130.0Kb
Man Pages (Zip) - 185.6Kb
Info (Gzip) - 3.3Mb
Info (Zip) - 3.3Mb

MySQL 8.0 Reference Manual  /  ...  /  mysql_character_set_name()

Pre-General Availability Draft: 2018-02-20 mysql_character_set_name()

const char *mysql_character_set_name(MYSQL *mysql)


Returns the default character set name for the current connection.

Return Values

The default character set name



User Comments
  Posted by Andy Dustman on January 5, 2005
With MySQL-4.0, mysql_character_set_name() does what you expect:

>>> import MySQLdb
>>> db=MySQLdb.connect(read_default_file="~/.my.cnf")
>>> db.character_set_name()

With MySQL-4.1, mysql_character_set_name() returns the collation, and not the character set name:

>>> import MySQLdb
>>> db=MySQLdb.connect(read_default_file="~/.my.cnf")
>>> db.character_set_name()

Tip or bug? Leaning towards bug. Note that examples are with MySQL-python-1.1.8; the first example is with MySQL-4.0.22, and the second with with 4.1.8.
  Posted by Andy Dustman on January 18, 2005
The problem above is supposedly fixed in 4.1.9 and 5.0.3.
  Posted by Daniel Murray on March 4, 2005
I'm having this problem with 4.1.10-nt-log. It's very frustrating, I spent ages trying to work out what was going on! I got around it (in MySQLdb) by changing the line in that says self.charset = self.character_set_name().split('_')[0] to read self.charset = 'utf8'. It's messy, obviously, but it works for me.
Sign Up Login You must be logged in to post a comment.