| View previous topic :: View next topic |
| Author |
Message |
llongi Retired Dev


Joined: 15 Apr 2004 Posts: 459 Location: Switzerland
|
Posted: Fri Mar 09, 2007 6:13 pm Post subject: |
|
|
| Joe User wrote: | | if i understand you correctly, i can drop the [php-$SAPI] sections from my.cnf without any sideeffects, because `emerge php` does not look at them anymore? And if so, will the now also unnecessary corresponding mysql-patches be removed too? |
You can drop them from my.cnf, yes, because PHP doesn't look at them anymore. Now PHP looks at the three php.ini directives I mentioned earlier, so just make sure those are set right, they are the only thing that matters now. Also the patches to PHP to read my.cnf were dropped, but we still do patch the MySQL extensions to get support for the *mysql*.connection_charset php.ini directives. Those normally don't exist, they're stuff I made up.  _________________ Best regards, Luca. |
|
| Back to top |
|
 |
fisk n00b

Joined: 29 Mar 2004 Posts: 63
|
Posted: Fri Mar 09, 2007 10:48 pm Post subject: |
|
|
| CHTEKK wrote: |
@fisk: Huh? The PHP update only changed the way PHP<->MySQL connections are set charset-wise, it's impossible that it actually changed the data IN your database, unless you also made some major upgrade of MySQL or something like that...
The PHP update should really be no problem, it actually should add the right directives itself to php.ini, and it's very simple how to fix it yourself if it does not:
Before, PHP looked at my.cnf, first the [php-$SAPI] section in there, then the [client] section, if you had set any particular charset stuff in one of those two, then it would use it.
Now, PHP just uses the php.ini setting, so you just have to set the same charset you were using in my.cnf (if you were using any!), and then restart Apache, and it will work exactly like before.
If it doesn't, I'm pretty sure it's not the fault of the new PHP ebuilds. |
Yes, MySQL was updated when I updated the system, it installed the latest apache, php, and mysql.
Updated deep world.
Everything went fine, except that from MySQL 4.4 -> 5.2 seems to have b0rkened the database. :/ - all passwords seem to work, it's just the language-specific characters that have been replaced with weirdness. _________________ -doh |
|
| Back to top |
|
 |
Joe User n00b


Joined: 21 Mar 2004 Posts: 10 Location: Germany
|
Posted: Sat Mar 10, 2007 1:19 pm Post subject: |
|
|
| CHTEKK wrote: | | Joe User wrote: | | if i understand you correctly, i can drop the [php-$SAPI] sections from my.cnf without any sideeffects, because `emerge php` does not look at them anymore? And if so, will the now also unnecessary corresponding mysql-patches be removed too? |
You can drop them from my.cnf, yes, because PHP doesn't look at them anymore. Now PHP looks at the three php.ini directives I mentioned earlier, so just make sure those are set right, they are the only thing that matters now. Also the patches to PHP to read my.cnf were dropped, but we still do patch the MySQL extensions to get support for the *mysql*.connection_charset php.ini directives. Those normally don't exist, they're stuff I made up.  |
OK, that's all i want to know. Thanks again for your great work! _________________ FreeBSD Remote Installation ¤ Gentoo Linux Remote Installation |
|
| Back to top |
|
 |
fisk n00b

Joined: 29 Mar 2004 Posts: 63
|
Posted: Mon Mar 12, 2007 9:29 pm Post subject: |
|
|
Would really like some help with my issue. Thanks. _________________ -doh |
|
| Back to top |
|
 |
rev138 l33t


Joined: 19 Jun 2003 Posts: 848 Location: Vermont, USA
|
Posted: Mon Mar 19, 2007 2:56 pm Post subject: |
|
|
| Joe User wrote: | Hi,
adding the following undocumented options to the php.ini (PHP-5.2.x) fixed the problem for our community:
| Code: |
mysql.connect_charset=latin1
mysqli.connect_charset=latin1
|
|
Ditto. Thanks!  _________________ Vermont Free PC
http://www.vtfreepc.org |
|
| Back to top |
|
 |
Robelix l33t


Joined: 21 Jul 2002 Posts: 760 Location: in a World created by a Flying Spaghetti Monster
|
Posted: Sat Jun 09, 2007 9:20 am Post subject: |
|
|
In an utf-8 system I have one vhost set to latin1:
| Code: |
<VirtualHost *:80>
[...]
AddDefaultCharset ISO-8859-1
php_value default_charset "iso-8859-1"
php_admin_value mysql.connect_charset "latin1"
php_admin_value mysqli.connect_charset "latin1"
</VirtualHost>
|
The database used by this vhost is latin1_german1_ci.
The result is strange: it works sometimes. I tried it with a little test-script:
| Code: |
<?
$config['db_server'] = 'localhost';
$config['db_user'] = '****';
$config['db_password'] = '****';
$config['db_database'] = '*****';
$config['db_prefix'] = '';
$link = mysql_pconnect($config['db_server'], $config['db_user'], $config['db_password']);
$encoding = mysql_client_encoding($link);
$fh = fopen('/tmp/encoding.txt', 'a');
fwrite($fh, $encoding."\n");
fclose($fh);
echo $encoding;
?>
|
After reloading this several thousand times /tmp/encoding.txt looks like:
line 1 - 129: latin1
line 130 - 326: utf8
line 327 - 556: latin1
line 557 - 717: utf8
line 718 - 1118: latin1
line 1119 - 1289: utf8
and so on...
How can this happen?
(php-5.2.2-r1 apache-2.0.58-r2 mysql-5.0.40) _________________ mysql> SELECT question FROM life, universe, everything WHERE answer=42;
Empty set (2079460347 sec) |
|
| Back to top |
|
 |
Joe User n00b


Joined: 21 Mar 2004 Posts: 10 Location: Germany
|
|
| Back to top |
|
 |
Robelix l33t


Joined: 21 Jul 2002 Posts: 760 Location: in a World created by a Flying Spaghetti Monster
|
Posted: Fri Jun 15, 2007 3:07 pm Post subject: |
|
|
| Joe User wrote: | | Are you getting the same results when using mysql_connect instead of mysql_pconnect? |
Using mysql_connect fixes this - 3500 times latin1 without a single utf8  _________________ mysql> SELECT question FROM life, universe, everything WHERE answer=42;
Empty set (2079460347 sec) |
|
| Back to top |
|
 |
Mathieu Bonnet n00b

Joined: 19 Nov 2005 Posts: 16 Location: (Left this forum)
|
Posted: Thu Sep 06, 2007 6:21 pm Post subject: |
|
|
If anyone still has some problem, check what exact string you are using to specify the charset.
If you use UTF-8, the string must be either "utf8" or "UTF8", but not "utf-8" or "UTF-8" (you must not use an hyphen). I modified the new options, manually, and didn't think the hypen would make a difference.
Also, it's "*mysql*.connect_charset", not "*mysql*.connection_charset" (typo in two of CHTEKK's posts -well, maybe you originally thought of using "connection_charset"?).
In conclusion, in the php.ini file that your Web server is using, you must have:
mysql.connect_charset = "utf8"
mysqli.connect_charset = "utf8"
pdo_mysql.connect_charset = "utf8"
If you use another charset than UTF-8, you should try to use the main charset name, from "/usr/share/mysql/charsets/Index.xml", instead of an alias (well, I guess it is where the problem is coming from -if anyone has some time to check this, and, possibly, report to the the appropriate person, please do, and thanks for this).
And as said by others, do not forget to restart your Apache server, for the PHP configuration to be taken into account (well, if you use the Apache PHP module).
AFAIC, I had the following MySQL server error, when trying to login with phpMyAdmin: "#2019 - Can't initialize character set UTF-8 (path: /usr/share/mysql/charsets/)".
Now, it works without problem. |
|
| Back to top |
|
 |
ewisnhu n00b

Joined: 23 Mar 2012 Posts: 1
|
Posted: Fri Mar 23, 2012 3:27 am Post subject: [SOLVED] "Can't initialize character set UTF-8" |
|
|
Hello there, sorry if this reply is rather late cause i just figured it out. This is my turn to share mine.
I followed your guys solution and based on that here's my way:
First, i got this: "Can't initialize character set UTF-8". (make sure the letter case)
Second, make sure the /etc/php5/apache2/php.ini have these: (again, make sure it's UTF-8 not utf-8 or else)
mysql.connect_charset = "UTF-8"
mysqli.connect_charset = "UTF-8"
pdo_mysql.connect_charset = "UTF-8"
Third, in /usr/share/mysql/charsets/Index.xml make sure you replaced utf-8 or utf8 for UTF-8,
you can search/find for utf8 or else to make sure.
Finally, restart mysql and apache2 service.
and alhamdulillah, it's working; i hope this will help anyone. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|