Answer the question
In order to leave comments, you need to log in
Encoding issues (ASP,ADO,Mysql,Win2008Server)
Today, the server suddenly went crazy and began to issue data from the database in cp1251, despite the fact that they are stored in it in utf8.
Who is to blame and what to do?
However, I'll start from the beginning:
There is a server with a website. On it Win2008 Server Standard (English)
Mysql 5.1, Mysql-odbc-connector, ASP (without .NET), IIS 7.
A site written in ASP is spinning. Until this morning everything was working fine.
The site takes data to display from the database. And there they are all stored in UTF8.
In my.ini, default-charset=utf8 is everywhere.
In a DB in each label in properties utf8. In the properties of the database - also utf8.
However, when querying from the database, the data goes to the CP1251. Where to dig?
PS I tried to reboot, reinstall mysql-odbc-connector. Unload the database dump, and upload it again - too.
Answer the question
In order to leave comments, you need to log in
Hello - this problem usually occurs when the connection encoding is Latin 1,
you can see the settings with the following query:
SHOW GLOBAL VARIABLES LIKE 'char%';
What is the result?
Then you can try adding charset=UTF8 to the connection string mysql-odbc
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress; charset=UTF8; Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;
In this case, try to see what MySQL has to say about the created table - try the following query:
SHOW CREATE TABLE `table_name`
As a result, we get something like:
CREATE TABLE `table_name` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name ` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8
Here we will see how it stores information in the table:
If you are sure that the data in the table is stored in cp1251, you can try
ALTER TABLE your_Table_Name MODIFY `Descr` varchar(255) CHARACTER SET utf8;
In general, I will wait for the programmer. I'm the admin. And with ASP it is familiar only by hearsay. And with Windows too.
look at the session code page - if another one is set, then everything will be successfully recoded
Thanks to all. The problem could not be solved. I was only able to get around.
I had to reinstall Windows on the backup server. And here, too, it did not immediately work as it should.
But there it turned out to be mysql variables (first answer by DenisIT).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question