考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
  当前位置:Linux认证 > 红帽认证 > 红帽认证辅导 > 文章内容
  

RHCE7认证学习笔记:MariaDB数据库配置与管理

来源:Linux社区 [ 2016年2月4日 ] 【

三、配置数据库

用户管理:

MariaDB [(none)]> use mysql;

MariaDB [mysql]> desc users;

MariaDB [mysql]> select host,user,password from user;

给用户root设置密码的方法:

1、

 [root@linuxidc ~]# mysqladmin -uroot -p password 'RedHat'

2、

 MariaDB [(none)]> set password=password('redhat');

3、

 MariaDB [(none)]> update mysql.user set password=password('redhat') where user='root' and host='localhost';

MariaDB [(none)]> flush privileges;

忘记root密码重新设置密码,使用以下2种方式重新修改密码:

1、修改my.cnf文件,加入以下语句:

skip-grant-tables

直接进入数据库无需密码,然后执行以下修改密码的命令:

MariaDB [(none)]> update mysql.user set password=password('redhat') where user='root' and host='localhost';

MariaDB [(none)]> flush privileges;

2、使用mysqld-safe命令修改密码

先停止mysqld服务,再修改密码:

 [root@linuxidc ~]# systemctl stop mariadb.service

[root@linuxidc ~]# mysqld_safe --skip-grant-tables

MariaDB [(none)]> update mysql.user set password=password('redhat') where user='root' and host='localhost';

MariaDB [(none)]> flush privileges;

创建普通用户并设置密码:

MariaDB [(none)]> create user redhat@'localhost';

MariaDB [(none)]> create user redhat@'%';任意主机

MariaDB [(none)]> set password for redhat@'localhost'=password('redhat');

给用户设置权限:

查看用户的权限:

MariaDB [(none)]> show grants for redhat;

查看系统的所有权限:

MariaDB [(none)]> show privileges;

授权给用户:

MariaDB [(none)]> grant create,insert,drop,update on school.* to redhat@'%' identified by 'redhat';

回收权限:

MariaDB [(none)]> revoke drop,update on school.* from redhat;

本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2007-2013 中华考试网(Examw.com) All Rights Reserved