使用MariaDB数据库管理系统

这篇具有很好参考价值的文章主要介绍了使用MariaDB数据库管理系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

初始化MariaDB服务

[root@localhost ~]# yum -y install mariadb mariadb-server
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

//再确认mariadb数据库软件程序安装完毕并成功启动后请不要立即使用。为了确保数据库的安全性和正常运转,需要做以下5个操作

1.设置root管理员在数据库中的密码值(该密码并非root管理员在系统中的密码,这里的密码值默认应该为空)

2.设置root管理员在数据库中的专有密码

3.删除匿名用户,并使用root管理员从远程登陆数据库,以确保数据库上的运行的业务安全性

4.删除默认的测试数据库,取消测试数据库的一些访问权限

5.刷新授权列表,初始化的设定立即生效

[root@localhost ~]# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):输入管理员密码,默认为空值,直接回车
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y(设置管理员密码)
New password:输入新的密码
Re-enter new password:再次输入密码
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y(删除匿名用户)
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y(禁止管理员从远程登陆)
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y(删除测试数据库及其权限)
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y(刷新授权表,让初始化设定立即生效)
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

实际生产环境中都是库站分离技术,需要修改防火墙放通服务(mysql)
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=mysql
success
[root@localhost ~]# firewall-cmd --reload
success

//使用刚才设置好的密码进行数据库登录
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

//修改root密码
MariaDB [(none)]> set password = password('linuxprobe');
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit
Bye
[root@localhost ~]# mysql -uroot -p
Enter password:(输入旧密码提示密码错误)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

//创建数据库普通用户

MariaDB [(none)]> create user luke@localhost identified by 'linuxprobe';
Query OK, 0 rows affected (0.000 sec)

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="luke";
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | luke | *55D9962586BE75F4B7D421E6655973DB07D6869F |
+-----------+------+-------------------------------------------+
1 row in set (0.000 sec)

//普通用户无太多数据库操作权限,需要对用户进行授权

grant 权限 on 数据库.表单名称 to 用户名@主机名(对某个特定数据库中的特定表单给予授权)
grant 权限 on 数据库.* to 用户名@主机名(对某个特定数据库中的所有表单给予授权)
grant 权限 on . to 用户名@主机名(对所有数据库及所有表单给予授权)
grant 权限1,权限2 on 数据库.* to 用户名@主机名(对某个数据库中的所有表单给予多个授权)
grant privileges on . to 用户名@主机名(对所有数据库中的所有表单给予全部授权,需谨慎操作)

//查看数据库用户权限

MariaDB [mysql]> show grants for luke@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for luke@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON . TO luke@localhost IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |
+-------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

//创建数据库

MariaDB [mysql]> create database linuxprobe;
Query OK, 1 row affected (0.001 sec)

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| linuxprobe         |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)

//创建表单

MariaDB [linuxprobe]> create table mybook (name char(15),price int,pages int);
Query OK, 0 rows affected (0.004 sec)

MariaDB [linuxprobe]> describe mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(15) | YES  |     | NULL    |       |
| price | int(11)  | YES  |     | NULL    |       |
| pages | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.001 sec)

//插入数据
MariaDB [linuxprobe]> insert into mybook(name,price,pages) values('linuxprobe','60','518');
Query OK, 1 row affected (0.001 sec)

MariaDB [linuxprobe]> select * from mybook;
+------------+-------+-------+
| name       | price | pages |
+------------+-------+-------+
| linuxprobe |    60 |   518 |
+------------+-------+-------+
1 row in set (0.000 sec)

//查找语句

Where命令中使用的参数及其作用

=:相等

<>或!=:不相等

>:大于

<:小于

>=:大于或等于

<=:小于或等于

BETWEEN:在某个范围内

LIKE:搜索一个例子

IN:在列表中搜索多个值

//数据库的备份与回复文章来源地址https://www.toymoban.com/news/detail-825772.html

[root@localhost ~]# mysqldump -u root -p linuxprobe > /root/linuxprobeDB.dump
Enter password:
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 21
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> drop database linuxprobe;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> create database linuxprobe;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> exit
Bye
[root@localhost ~]# mysql -u root -p linuxprobe < /root/linuxprobeDB.dump
Enter password:
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 23
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use linuxprobe;
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 [linuxprobe]> show tables;
+----------------------+
| Tables_in_linuxprobe |
+----------------------+
| mybook               |
+----------------------+
1 row in set (0.000 sec)

MariaDB [linuxprobe]> describe mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(15) | YES  |     | NULL    |       |
| price | int(11)  | YES  |     | NULL    |       |
| pages | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.000 sec)

到了这里,关于使用MariaDB数据库管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Android期末大作业:使用AndroidStudio开发图书管理系统APP(使用sqlite数据库)

    Android Studio开发项目图书管理系统项目视频展示: 点击进入图书管理系统项目视频 现在是一个信息高度发达的时代,伴随着科技的进步,文化的汲取,人们对于图书信息的了解与掌握也达到了一定的高度。尤其是学生对于知识的渴求更是与日俱增。图书馆作为学生学习知识的

    2024年02月08日
    浏览(39)
  • MariaDB 使用 root 账户管理数据库用户权限和远程登录权限设置

    MariaDB 使用 root 账户管理数据库用户权限和远程登录权限设置 作为一种流行的关系型数据库管理系统,MariaDB 提供了丰富的功能和灵活的权限控制机制。在本文中,我们将学习如何使用 root 账户来创建新用户,并为其分配特定的数据库权限和远程登录权限。 首先,我们需要使

    2024年01月23日
    浏览(36)
  • 基于SpringBoot 2+Layui实现的管理后台系统源码+数据库+安装使用说明

    一个基于SpringBoot 2 的管理后台系统,包含了用户管理,组织机构管理,角色管理,功能点管理,菜单管理,权限分配,数据权限分配,代码生成等功能 相比其他开源的后台系统,SpringBoot-Plus 具有一定的复杂度 系统基于Spring Boot2.1技术,前端采用了Layui2.4。数据库以MySQL/Oracle

    2024年02月04日
    浏览(36)
  • 数据库管理系统(基于前端+后端+数据库)

      库存管理系统 包括模块: (1)基本信息管理。 (2)商品入库管理。 (3)商品出库管理。 (4)商品查询管理。 (5)查看商品目录。 实训步骤: 开发环境:html , css , js , python,Mysql,pycharm 需求分析: 和其他数据库系统相比, MySQL 有点与众不同,它的架构可以在多种

    2024年02月04日
    浏览(55)
  • 数据库应用:数据库管理系统与安装MySQL数据库

    目录 一、理论 1.数据库管理系统 2.关系型数据库 3.数据库 4.MySQL数据库 5.MySQL部署 二、实验 1.yum安装MySQL 2.编译安装MySQL 3.配置MySQL数据库的Tab补全  三、问题 1.数据库登录报错 2.数据库密码复杂度报错 3.数据库连接报错 四、总结 (1)概念 数据库管理系统(Database Management

    2024年02月13日
    浏览(43)
  • 数据库系统课程设计(高校成绩管理数据库系统的设计与实现)

    目录 1、需求分析 1 1.1 数据需求描述 1 1.2 系统功能需求 3 1.3 其他性能需求 4 2、概念结构设计 4 2.1 局部E-R图 4 2.2 全局E-R图 5 2.3 优化E-R图 6 3、逻辑结构设计 6 3.1 关系模式设计 6 3.2 数据类型定义 6 3.3 关系模式的优化 8 4、物理结构设计 9 4.1 聚簇设计 9 4.2 索引设计 9 4.3 分区设

    2024年02月03日
    浏览(51)
  • MySQL数据库:数据库管理系统与安装MySQL数据库

    目录 一、理论 1.数据库管理系统 2.关系型数据库 3.数据库 4.MySQL数据库 5.MySQL部署 二、实验 1.yum安装MySQL 2.编译安装MySQL 3.配置MySQL数据库的Tab补全  三、问题 1.数据库登录报错 2.数据库密码复杂度报错 3.数据库连接报错 四、总结 (1)概念 数据库管理系统(Database Management

    2024年02月12日
    浏览(43)
  • 数据库系统课设--人事管理系统

    目录 前言 一,课程设计的目的 二,总体设计 1 系统需求分析 1.1 系统功能分析 1.2 系统功能模块设计(划分) 1.3 与其它系统的关系 1.4 数据流程图 2 数据库设计 2.1 数据库需求分析 2.2 数据库概念结构设计 2.3 数据库逻辑结构设计 2.4 数据库的建立 2.4.1 数据库的建立 2.4.2 初始

    2024年02月06日
    浏览(43)
  • 网吧管理系统数据库设计

    摘  要:网吧管理系统是为解决大型网吧面临的复杂电脑管理业务流程和繁琐的客户服务、信息处理业务而开发的管理系统。它主要包含系统管理、会员管理、日常管理、查询管理、统计报表五个模块。数据库设计过程中主要进行了分析网吧电脑使用业务方面的需求,进行概

    2024年02月08日
    浏览(44)
  • 学生信息管理系统(数据库)

    要求实现功能: (1)学生、课程、教师等信息的录入和维护,一门课只由一位教师上,一位教师可上多门课 (2)学生进行选课,一学期约20学分 (3)教师在每门课结束后给出学生成绩,不及格则补考后记录补考成绩 (4)能明细查询某学生的选课情况及某课程的选修学生情

    2024年02月03日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包