Question

It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?

Was it helpful?

Solution

In your Mysql configuration change the default-character-set operative under the [mysqld] tab. For example:

[mysqld]
default-character-set=utf8

Don't forget to restart your Mysql server afterwards for the changes to take effect.

OTHER TIPS

For Linux:

  1. You need to have access to the MySQL config file.
    The location can vary from /etc/mysql/my.cnf to ~/my.cnf (user directory).

  2. Add the following lines in the section [mysqld]:

    collation_server = utf8_unicode_ci
    character_set_server=utf8
    
  3. Restart the server:

    service mysqld restart
    

This is not a phpMyAdmin question.

Collations are part of recent MySQL releases, you must set the default collation of the server (or at least of the database) to change that behaviour.

To convert already imported tables to UTF-8 you can do (in PHP):

$dbname = 'my_databaseName';
mysql_connect('127.0.0.1', 'root', '');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$res = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($res)) {
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
}
echo 'all tables converted';

Code snippet taken from here.

know this is an old post. But the way i changed the default charset through phpMyAdmin was:

phpMyadmin main page > Variables tab (Server variables and settings) > searched for "character" and changed all variables from "latin1" to "utf8". (on a MAMP installation with phpMyAdmin v. 3.5.7)

And as the others said, this is the variables for MySQL and not some phpMyAdmin specific ones.

MySQL DB « change Collation Name of a Database|Table to utf8_general_ci inorder to support Unicode.

Change Configuration settings file also


XAMPP: uncomment UTF 8 Settings from the Configuration settings file « D:\xampp\mysql\bin\my.ini

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
character_sets-dir="D:/xampp/mysql/share/charsets"

For MySQL server to support UTF8 and the below line of code in file my.cnf

## UTF 8 Settings
collation_server=utf8_unicode_ci
character_set_server=utf8

@see

For utf8mb4, add/change the following in the [mysqld] section:

collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4

Then restart the mysql service (for Ubuntu the command is sudo service mysql restart)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top