Centosでmariadbをインストールする
1.MariaDBのインストール
#yum -y install mariadb mariadb-server
MariaDBが起動
#systemctl start mariadb
自動起動
#systemctl enable mariadb
MariaDBの設定
#mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n]
New password:
Re-enter new password:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
ログイン
mysql -u root -p password
2.MariaDBの文字エンコード
#vi /etc/my.cnf
[mysqld]追加
init_connect=’SET collation_connection = utf8_unicode_ci’
init_connect=’SET NAMES utf8’
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
設定ファイル /etc/my.cnf.d/client.cnf
#vi /etc/my.cnf.d/client.cnf
[client]追記
default-character-set=utf8
設定ファイル/etc/my.cnf.d/mysql-clients.cnf
#vi /etc/my.cnf.d/mysql-clients.cnf
[mysql]追記
default-character-set=utf8
mariadb再起動
systemctl restart mariadb
MariaDBのcharacterの確認
mysql> show variables like “%character%";show variables like “%collation%";
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| 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 | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)
+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+———————-+—————–+
3 rows in set (0.00 sec)