Centos7 安装Mariadb

Centos7 安装Mariadb

1) 安装前查看-了解总结

Centos7 原生安装了Mariadb, 并且可以看到在/etc/my.cnf文件

但是不知道如何启动,启动不了
索性直接删除了安装包,自己重新安装

2)yum安装Mariadb

#1) 修改为国内的源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repo.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#2) 安装mariadb
yum -y install mariadb mariadb-server mariadb-devel

3) 查看安装后文件目录




# 启动mariadb并设置开机自启动
systemctl start mariadb
systemctl enable mariadb
# 查看启动
netstat -ntlp | grep mysql

4) 修改配置文件

# 修改字符集
vim /etc/my.cnf
# [mysql] 下添加如下内容
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
vim /etc/my.cnf.d/client.cnf
# [client] 下添加
default-character-set=utf8
vim /etc/my.cnf.d/mysql-clients.cnf
# [mysqld] 下添加
default-character-set=utf8

# 重启mariadb
systemctl restart mariadb

# 开启mariadb客户端
mysql
show variables like "character%";
show variables like "collation%";

5)通过mysql_secure_installation命令 进行安全配置

# 输入该条命令,按照提示操作
mysql-secure-installation

# 删除匿名用户,删除test库,设置root的登录密码

# 查看当前用户
select user()
# or
select User,host from mysql.user;

6) 改权限root用户可远程登录

grant all privileges on *.* to 'root'@'%' identified by 'mysql' with grant option;
flush privileges;

posted @ 2020-09-20 23:30  pigeast  阅读(702)  评论(0编辑  收藏  举报