Edit report at https://bugs.php.net/bug.php?id=44118&edit=1
ID: 44118
Comment by: shane dot bester at oracle dot com
Reported by: slava_reg at nsys dot by
Summary: [PATCH] MySQL: Set connection charset via php.ini
option
Status: Wont fix
Type: Feature/Change Request
Package: MySQL related
Operating System: any
PHP Version: 5.2.5
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
in my above case, i can connect only if i start server with
--skip-character-set-
client-handshake option
Previous Comments:
------------------------------------------------------------------------
[2013-02-06 03:09:05] shane dot bester at oracle dot com
I compiled my server with default charset of utf32. Now I cannot connect at
all,
therefore cannot execute any SET NAMES command. So, this needs fixing.
PHP Warning: mysqli_connect(): (HY000/1231): Variable 'character_set_client'
can't be set to the value of 'utf32' in X line Y
------------------------------------------------------------------------
[2011-10-18 12:58:41] [email protected]
mysqli has this. You can create a connection with mysqli_init() or just new
mysql() and then call mysqli_options() or $link->options and set the charset to
be used. It will be negotiated during the client-server handshake and there
will be no additional query like SET NAMES. mysqli_options() works before
connections is established, later it has no effect.
------------------------------------------------------------------------
[2011-02-24 14:15:45] cavo at ynet dot sk
This is not about making application utf8 compatible. You can do this by "set
names" query. But it may be redundant. For example: All my database is in utf8
encoding. All my pages have content-type utf8. All form posts from clients are
in utf8. All strings I process in application are utf8. But what do I need to
do right after I connect to database? - "set names utf8;" Why? Because if I
don't, db will re-encode all strings to latin1. And PHP don't care. If I have
100 new connections to db per second, I need to 100 times run that query. Why
if client and server could negotiate encoding in those 2 obliged packets? (
http://bugs.php.net/bug.php?id=54086 ). It's ok to set latin1 as default
character set used by client to not affect existing applications (I believe
mostly for those, who actualy don't know, what are they doing..). But I think
it's very useful to have option to set encoding manualy via configuration
option or in connect functions like: mysql_connect('localhost', 'user', 'pwd',
true, MYSQL_CLIENT_ENCODING_UTF8);
Or am I somwhere wrong?
http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#Client_Authentication_Packet
http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_default-character-set
http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_character-set-client-handshake
http://bugs.php.net/bug.php?id=54086
------------------------------------------------------------------------
[2011-01-31 11:52:36] [email protected]
The application has to know the encoding being used, else some strange things
might happen. We have seen the trouble in having this globally configurable
when Gentoo decided to use Utf-8 for their MySQL installations by default
instead of MySQL's default. I doubt you can make an application Utf-8
comaptible by just setting such a low-level switch (it won't affect the HTTP
Content-type header or HTML forms, thus receiving data in a wrong encoding from
the user, not re-encode it etc.)
------------------------------------------------------------------------
[2011-01-06 16:19:52] [email protected]
Not sure if this is really needed. It can be done in user land. Its a bit of a
convenience feature. Not many votes for it... Andrey, Johannes...?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=44118
--
Edit this bug report at https://bugs.php.net/bug.php?id=44118&edit=1