본문 바로가기
FrameWork/CodeIgniter

Mysql 버전으로 인한 문제

by 백룡화검 2008. 6. 30.

MySQL 4.0

When attempting to connect to or use MySQL 4.0 or below as a database with CodeIgniter 1.6 and above, you’ll need to make the following adjustments, as there is a compatibility issue.

First a bit of an explanation: CI 1.6 now uses a feature of MySQL 4.1> called character sets and collation. These are not supported in MySQL 4.0 and below. Well, they are supported, just not in the same fashion as 4.1 and above.

If you attempt to connect to a MySQL 4.0 DB, you’ll get this error:

*An Error Was Encountered
*Unable to set client connection character set: utf8

If you look at CI 1.6’s database.php (system/application/config/) you’ll see two new lines of code at the bottom of the DB config block:

$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

These are used to set the character set and collation for the database to which you are connecting.

This is the adjustment you’ll need to (temporarily) make to achieve a connection:
Open up system/database/drivers/your_driver/your_driver_driver.php Find the db_set_charset() function, in the MySQL driver this is around line 95.  Change it to say:

function db_set_charset($charset, $collation)
{
return TRUE;
}

I’d just comment out the existing line, as this is a somewhat temporary fix.

Test your connection—you should be good to go.

See this forum post for more clarification:
http://codeigniter.com/forums/viewthread/70698

One final note: If at all possible, move away or upgrade from mysql 4.0, as it is no longer supported by MySQL (since 2006) and after december 2008, will no longer receive security updates.

Lastly, according to a Codeigniter admin, there are other additional upcoming features that will require MySQL 4.1 and above.

[출처] Mysql 버전으로 인한 문제|작성자 행복나눔