mariadb安装配置
1. 创建/etc/yum.repos.d/MariaDB.repo文件
vim /etc/yum.repos.d/MariaDB.repo
添加如下:
[mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
2. 使用yum来安装
yum -y install MariaDB-server MariaDB-client
3. 启动服务
systemctl start mariadb #启动服务 systemctl enable mariadb #设置开机启动 systemctl restart mariadb #重新启动 systemctl stop mariadb.service #停止MariaDB systemctl status mariadb.service #查看状态
4. 设置ROOT密码
mysqladmin -u root password 123456
5. 登陆mysql
mysql -uroot -p123456
6. 授权root远程登录
root可从任何IP登陆,注意修改密码:'123456'
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
7.配置MariaDB的字符集
使用vim /etc/my.cnf.d/server.cnf命令编辑server.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
systemctl restart mariadb
mysql -uroot -p123456
show variables like "%character%";show variables like "%collation%";