mysql – Change "character" and "collation" setting

Question:

I have a configuration in a database as follows:


SERVIDOR 1

show variables like '%version%';

innodb_version           1.1.8
protocol_version         10
slave_type_conversions  
version                  5.5.19-log
version_comment          MySQL Community Server (GPL) by Remi
version_compile_machine  x86_64
version_compile_os       Linux

show variables like '%character%';

character_set_client     utf8
character_set_connection utf8
character_set_database   latin1
character_set_filesystem binary
character_set_results    utf8
character_set_server     latin1
character_set_system     utf8
character_sets_dir       /usr/share/mysql/charsets/

show variables like 'collation%';

collation_connection     utf8_general_ci
collation_database       latin1_swedish_ci
collation_server         latin1_swedish_ci

And on the other Server, configuration as follows:

SERVIDOR 2

show variables like '%version%';

innodb_version           5.6.22
protocol_version         10
slave_type_conversions  
version                  5.6.22-log
version_comment          MySQL Community Server (GPL)
version_compile_machine  x86_64
version_compile_os       Win64

show variables like '%character%';

character_set_client     utf8
character_set_connection utf8
character_set_database   utf8
character_set_filesystem binary
character_set_results    utf8
character_set_server     utf8
character_set_system     utf8
character_sets_dir       C:\Program Files\MySQL\MySQL Server 5.6\share\charsets\

show variables like 'collation%';

collation_connection     utf8_general_ci
collation_database       utf8_general_ci
collation_server         utf8_general_ci

I need Server 2 to be identical to Server 1. Note that the configuration difference is in the following items:

character_set_database  (alterar para "latin1")
character_set_server    (alterar para "latin1")
collation_database      (alterar para "latin1_swedish_ci")
collation_server        (alterar para "latin1_swedish_ci")

I tried using the "SET" commands, but it didn't work, even by the command line.

Is it possible to change? How to make?

I appreciate the help!

Answer:

This is quite simple, just change the character and collate of your server 2 database:

ALTER DATABASE tua_Base_de_Dados DEFAULT CHARACTER SET latin1 COLLATE=latin1_swedish_ci;

And as it says in this answer add these lines in the /etc/mysql/my.cnf file

[mysqld]
character_set_database=latin1
character_set_server=latin1
Scroll to Top