CentOS MariaDB 安装和配置

sudo vi /etc/yum.repos.d/mariadb.repo

# MariaDB 10.1 CentOS repository list - created 2017-03-23 13:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

#保存退出 :wq

sudo sed -i 's#yum.mariadb.org#mirrors.ustc.edu.cn/mariadb/yum#' /etc/yum.repos.d/mariadb.repo

# 或者使用 HTTPS
sudo sed -i 's#http://mirrors.ustc.edu.cn#https://mirrors.ustc.edu.cn#g' /etc/yum.repos.d/mariadb.repo

#若安装时遇到错误 “Failed to connect to 2001:da8:d800:95::110: Network is unreachable”,将源地址中的 mirrors.ustc.edu.cn替换为 ipv4.mirrors.edu.cn 以强制使用 IPv4:
sudo sed -i 's#//mirrors.ustc.edu.cn#//ipv4.mirrors.ustc.edu.cn#g' /etc/yum.repos.d/mariadb

sudo yum update

#安装命令
sudo yum install MariaDB-server MariaDB-client

sudo service mariadb start
service mariadb status

#root 不设置密码,默认
sudo mysql_secure_installation

#允许远程访问
sudo vi /etc/my.cnf.d/server.cnf
bind-address = 0.0.0.0
:wq

sudo service mariadb restart

sudo adduser dbuser

#登陆到mysql
mysql -u root
use mysql;

#####update user SET Host='%' where User='root'and Host='localhost';

INSERT INTO mysql.user (Host, User, Password) VALUES ('%', 'dbuser', password('dragon'));

GRANT ALL ON *.* TO 'dbuser'@'%' WITH GRANT OPTION;
flush privileges;

#配置字符集

set character_set_client = utf8 ;
set character_set_connection=utf8 ;
set character_set_database = utf8 ;
set character_set_results = utf8 ;
set character_set_server =utf8 ;

SET collation_server= utf8_general_ci;
SET collation_connection= utf8_general_ci;
SET collation_database= utf8_general_ci;

#exit
#修改配置
sudo vi /etc/my.cnf.d/server.cnf

[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
#init-connect=’SET NAMES utf8′

#:wq 保存退出

#and restart mysql
sudo service mariadb restart

# 查询数据库使用的字符集和排序
mysql -u root
show variables like '%colla%';
show variables like '%chara%';

#防火墙

sudo firewall-cmd --add-service=mysql --permanent #开放服务
sudo firewall-cmd --reload #重载防火墙

上一篇:Currency Exchange 分类: POJ 2015-07-14 16:20 10人阅读 评论(0) 收藏


下一篇:linux下的php网站放到Windows服务器IIS下导入 .htaccess文件伪静态规则转换 (wordpress)