This example environment installs MARIADB 5.5.56 for CentOS 7.4 yum
Environment Preparation: Create Latin1 encoded libraries, tables, data
MySQL--default-character-set=latin1
Show variables like ' char% ';
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/22/5aa88edd6aaad80fa52253a1bf77a43f.png "title=" QQ picture 20171122112812.png "alt=" 5aa88edd6aaad80fa52253a1bf77a43f.png "/>
Create database Latin;
Show create database Latin;
Use Latin
CREATE TABLE student (ID int,name varchar (), Age Int,class varchar (20));
INSERT into student values (1, ' Zhang San ', 18, ' math ');
INSERT into student values (2, ' John Doe ', 28, ' languages ');
Show create table student;
SELECT * from student;
650) this.width=650; "src=" Https://s2.51cto.com/oss/201711/22/e5647a87bb26387986fa00991040b763.png "title=" QQ picture 20171122113014.png "alt=" E5647a87bb26387986fa00991040b763.png "/>
Official start:
1 Backing up data
Mysqldump--default-character-set=latin1 Latin >latin.sql
2 Modifying the server-side configuration file
Vi/etc/my.cnf added in [mysqld] Segment
Character_set_server = UTF8
3 Restarting the service takes effect
Systemctl Stop MARIADB
Systemctl Start mariadb
4 changing character encoding to UTF8
Sed-n S/LATIN1/UTF8/GP Latin.sql
Sed-i s/latin1/utf8/g Latin.sql
5 Creating a new library import data
MySQL--default-character-set=utf8
Show variables like ' char% ';
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/22/6769216433c8f11a993095f200e3a552.png "title=" QQ picture 20171122112916.png "alt=" 6769216433c8f11a993095f200e3a552.png "/>
Create Database UTF8;
Show create Database UTF8;
Use UTF8
Source/root/latin.sql
6 Verification
SELECT * from student;
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/22/d5fb21ff2bfd724e88c76c87504b595e.png "title=" QQ picture 20171122113038.png "alt=" D5fb21ff2bfd724e88c76c87504b595e.png "/>
MySQL Latin 1 convert to UTF8