maria是一个人名,mariadb数据库是MySQL数据库的分支,主要由开源社区进行维护和更新。
和MySQL数据库一样,mysqld也是mariadb数据库软件提供服务的进程的名称。
目录
初始化mariadb服务
安装mariadb数据库
yum install mariadb mariadb-server -y
mariadb软件里包含了很多客户端的工具
mariadb-server是真正提供数据库服务的软件
启动mariadb服务
systemctl start mariadb
service mariadb start (二选一)
# 设置mariadb服务开机自启
systemctl enable mariadb
# 为了确保数据库的安全性和正常运转,需要先对mariadb数据库程序进行初始化操作
[root@localhost ~]# mysql_secure_installation
输入以上命令可以为root管理员设置数据库密码、删除匿名账户、禁止root管理员从远程登录、删除默认的测试数据库并取消对它的访问权限、刷新授权表让初始化后的设定立即生效
# 关闭防火墙或者设置防火墙策略,使其放行对数据库服务程序的访问请求
systemctl stop firewalld
systemctl disable firewalld
或
firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload
登录mariadb数据库
mysql -uroot -p
mysql -u root -p (二选一)
-uroot表示指定使用root用户登录
修改数据库用户密码的三种方法
(1)使用grant修改
grant all on *.* to 用户名@主机名 identified by '密码';
# 举例
MariaDB [(none)]> grant all on *.* to root@localhost identified by '499499';
Query OK, 0 rows affected (0.000 sec)
(2)使用alter修改
alter user 用户名@主机名 identified by '密码';
# 举例
MariaDB [(none)]> alter user root@localhost identified by '499499';
Query OK, 0 rows affected (0.000 sec)
(3)使用set修改
set password for 用户名@主机名 = password('密码');
# 举例
MariaDB [(none)]> set password for root@localhost = password('123456');
Query OK, 0 rows affected (0.000 sec)
管理账户以及授权
在生产环境中为了保障数据库系统的安全性,以及让其他用户协同管理数据库,我们可以在MariaDB数据库管理系统中为他们创建多个专用的数据库管理账户,然后再分配合理的权限,以满足工作需求。为此,我们可以使用root管理员登录数据库,然后按照一定的格式创建数据库管理账户。
创建账户的格式
create user 用户名@主机名 identified by '密码';
创建账户suda
MariaDB [(none)]> create user suda@localhost identified by '499499';
Query OK, 0 rows affected (0.001 sec)
查询账户suda的主机名称、账户名称以及加密后的密码信息
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> select host,user,password from user where user='suda';
+-----------+------+----------------------