三、配置数据库
用户管理:
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;
2015职称计算机考试书PowerPoint2007中 .. 定价:¥45 优惠价:¥42 更多书籍 | |
2015年全国职称计算机考试教材(2007模 .. 定价:¥225 优惠价:¥213 更多书籍 |