MariaDB修改默认字符集
MariaDB修改默认字符集,以及创建数据库授权
1 . 修改server默认字符集utf8
[root@aws my.cnf.d]# vim /etc/my.cnf.d/server.cnf
[mysqld]
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
修改client默认字符集utf8
[root@aws etc]# vim my.cnf.d/client.cnf
[client]
default-character-set=utf8
2 . 重启服务:
[root@aws my.cnf.d]# systemctl restart mariadb.service
3 . 查看字符集
MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";
4 . 创建库:
CREATE DATABASE aws_awshost;
GRANT ALL PRIVILEGES ON awshost.* TO 'aws_awshost'@'localhost' IDENTIFIED BY '*********';
GRANT ALL PRIVILEGES ON awshost.* TO 'aws_awshost'@'192.168.%' IDENTIFIED BY '*********';
**5 . 修改已存在的库字符集为utf8mb4 **
原文:https://help.aliyun.com/knowledge_detail/41692.html
# 修改库:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# 修改表:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# 修改一列:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;