CentOS安装MariaDB

1、安装

yum -yinstallmariadb mariadb-server

2、设置开机启动并启动

systemctl enable mariadb

systemctl start mariadb

3、配置数据库

mysql_secure_installation

Enter current password for root (enter for none) 设置密码第一次直接回车

move anonymous users? [Y/n]    删除匿名用户

Disallow root login remotely? [Y/n]  禁止root远程登录

Remove test database and access to it? [Y/n]   删除test数据库

Reload privilege tables now? [Y/n]    重新加载权限表

3、测试是否可以登陆

mysql -u用户名 -p密码

4、配置字符集支持 utf8mb4支持emoji

vi /etc/my.cnf

[client]

default-character-set = utf8mb4

[mysql]

default-character-set = utf8mb4

[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'

skip-character-set-client-handshake

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4'

vi /etc/my.cnf.d/client.cnf

[client]

default-character-set = utf8mb4

vi /etc/my.cnf.d/mysql-clients.cnf

[mysql]

default-character-set = utf8mb4

5、 重启

systemctl restart mariadb

6、登陆测试,命令别忘记分号

mysql -u用户名 -p密码

show variables like"%character%"; 

show variables like"%collation%";

输入正常为下面这种

+--------------------------+----------------------------+

| Variable_name            | Value                      |

+--------------------------+----------------------------+

| character_set_client    | utf8mb4                    |

| character_set_connection | utf8mb4                    |

| character_set_database  | utf8mb4                    |

| character_set_filesystem | binary                    |

| character_set_results    | utf8mb4                    |

| character_set_server    | utf8mb4                    |

| character_set_system    | utf8                      |

| character_sets_dir      | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

+----------------------+--------------------+

| Variable_name        | Value              |

+----------------------+--------------------+

| collation_connection | utf8mb4_unicode_ci |

| collation_database  | utf8mb4_unicode_ci |

| collation_server    | utf8mb4_unicode_ci |

+----------------------+--------------------+

你可能感兴趣的:(CentOS安装MariaDB)