创建一个 MariaDB 数据库,名为 Contacts,并符合以下条件: 数据库只能被 localhost 访问 除了 root 用户,此数据库只能被用户 Raikon 查询,此用户密码为 atenorth root 用户的密码为 atenorth,同时不允许空密码登陆
1)安装、配置
[[email protected] ~]# yum -y install mariadb-server mariadb
[[email protected] ~]# vim /etc/my.cnf
[mysqld]
skip-networking //添加此行,跳过网络
[[email protected] ~]# systemctl restart mariadb
[[email protected] ~]# systemctl enable mariadb
2)设密码、建库
[[email protected] ~]# mysqladmin -u root -p password 'atenorth' //设置密码
[[email protected] ~]# mysql -u root -p
MariaDB [(none)]> create database Contacts;
MariaDB [(none)]> grant select on Contacts. to [email protected] identified by 'atenorth';
MariaDB [(none)]> delete from mysql.user where Password=''; //删除空密码账号
MariaDB [(none)]> QUIT
转载于:https://blog.51cto.com/13673837/2331276