升级MariaDB为10.1版本

CentOS中升级mariadb为10.1GA版本。

1、如果有,停止服务

systemctl stop mariadb

2、卸载原来的数据库服务

yum -y remove mari*

3、删除数据库文件

rm -rf /var/lib/mysql/*

4.创建/etc/yum.repos.d/MariaDB.repo文件

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

配置系统网络:

41db4c90d7929e465f8dec9e922f3c206c9.jpg

yum clean all

yum makecache

5、安装MariaDB

yum -y install mariadb mariadb-server

6、启动MariaDB

systemctl start mariadb

7、设置开机启动

systemctl enable mariadb

8、接下来进行MariaDB的相关简单配置

mysql_secure_installation

首先是设置密码,会提示先输入密码

Enter current password for root (enter for none):    {回车}

Set root password? [Y/n]    {是否设置root用户密码,输入y并回车或直接回车}

New password: {设置root用户的新密码}

Re-enter new password:{确认密码}

Remove anonymous users? [Y/n] {是否删除匿名用户,回车}

Disallow root login remotely? [Y/n] {是否禁止root远程登录, 输入n回车}

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

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

9、配置MariaDB的字符集

vi /etc/my.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
vi /etc/my.cnf.d/client.cnf

在[client]中添加

default-character-set=utf8
vi /etc/my.cnf.d/mysql-clients.cnf

在[mysql]中添加

default-character-set=utf8

10、全部配置完成,重启mariadb

systemctl restart mariadb

11、登录mariadb

mysql -u root -p

输入刚才设置的密码进行登录

12、验证设置的字符集

show variables like "%character%";

e80c45f695390bcca6bbbc4eae37862e27f.jpg

show variables like "%collation%";

efb552232fb66db443b8d017d6f9747df1c.jpg

字符集配置完毕

13、添加用户,设置权限

创建用户命令

mysql>create user username@localhost identified by 'password';

直接创建用户并授权的命令

mysql>grant all on *.* to username@localhost identified by 'password';

这里我们执行下面这条授权即可

授予外网登陆权限 第一个root 代表用户名第二个root 代表该用户名对应的密码

mysql>grant all privileges on *.* to root@'%' identified by 'root';

授予权限并且可以授权

mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;

简单的用户和权限配置基本就这样了。

其中只授予部分权限把 其中 all privileges或者all改为select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。

 

 

转载于:https://my.oschina.net/shxjinchao/blog/1935037

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值