广告
返回顶部
首页 > 资讯 > 数据库 >mariadb数据库服务
  • 868
分享到

mariadb数据库服务

2024-04-02 19:04:59 868人浏览 安东尼
摘要

什么是mariadb?        MariaDB数据库管理系统是Mysql的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容my


什么是mariadb?
       MariaDB数据库管理系统是Mysql的一个分支,主要由开源社区在
维护,采用GPL授权许可 MariaDB的目的是完全兼容mysql,包括api
命令行,使之能轻松成为Mysql的代替品。在存储引擎方面,使用XtraDB
(英语:XtraDB)来代替MySQL的InnoDB。    MariaDB由MySQL的
创始人Michael Widenius(英语:Michael Widenius)主导开发,他早
前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,
随着SUN被甲骨文收购,MySQL的所有权也落入oracle的手中。MariaDB
名称来自Michael Widenius的女儿Maria的名字。

1.Mariadb安装  

    1-1安装mariadb和mariadb-client组件:    
        # yum groupinstall -y mariadb mariadb-client  
    1-2启动mariadb服务:    
         # systemctl start mariadb ; systemctl enable mariadb  
[root@server1 ~]# ss -antple|grep mysql
LISTEN     0      50                        *:3306                     *:*      
users:(("mysqld",2622,13)) uid:27 ino:36479 sk:ffff8800235a0000 <->

    1-4编辑/etc/my.cnf文件,在[mysqld]中加入以下参数:        
        skip-networking=1    
    1-5# systemctl restart mariadb      
        # ss -antlp |grep mysql     此时只允许通过套接字文件进行本地连接,阻断
        所有来自网络tcp/ip连接。
2.使用mysql_secure_installation工具进行数据库安全设置,根据提示完成
   操作:
 
          # mysql_secure_installation
[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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]
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]
... 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]
... 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]
- 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]
... 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!
[root@server1 ~]#

3.登录数据库:    

          # mysql -u root -p Enter password: redhat MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> quit
4.数据库基本操作SQL
show databases;                            显示数据库 use mysql;                            进入数据库 show tables;                            显示数据库中的表 desc user;                            查看user表的数据结构 flush privileges;                        刷新数据库信息 select host.user,password from user;                查询user表中的host,user,password字段 create database westos;                        创建westos数据库 use westos;                             create table linux(                        创建表,username,password字段 username varchar(15) not null, password varchar(15) not null ); select * from mysql.user;                    查询mysql库下的user表中的所以 alter table linux add age varchar(4);                添加age字段到linux表中 alter table linux drop age; alter table linux add age varchar(4) after username; show tables; desc linux; insert into linux values ('user1','passwd1');                在linux表中插入值为username = user1,password = password1 update linux set password=password('passwd2') where username=user1;    更新linux表中user1 的密码为password2 delete from linux where username=user1;                    删除linux表中user1的所以内容
5.mysql 密码恢复  
          1)#systemctl stop mariadb  
          2)#mysql_safe --skip-grant &  
          3)#mysql        
          update mysql.user set password=password('westos') where user='root';    更新mysql.user 表中条件为root用户的密码为加密westos   4)killall -9  mysqld_safe     ps -aux | grep mysql     kill -9 ****    5)systemctl start mariadb
6.用户和访问权限
创建用户CREATE USER wxh@localhost identified by 'westos'; CREATE USER lee@'%' identified by 'redhat';用户授权GRANT INSERT,UPDATE,DELETE,SELECT on mariadb.* to wxh@localhost; GRANT SELECT on mariadb.* lee@'%';重载授权表FLUSH PRIVILEGES;查看用户授权SHOW GRANTS FOR wxh@localhost;撤销用户权限REVOKE DELETE,UPDATE,INSERT on mariadb.* from wxh@localhost;删除用户DROP USER wxh@localhost;
7.备份与恢复
备份# mysqldump -uroot -predhat westos > westos.dump # mysqldump -uroot -predhat --all-databases > backup.dump # mysqldump -uroot -predhat --no-data westos > westos.dump   ##只备份框架,不备份数据。恢复# mysqladmin -uroot -predhat create db2 或 mysql -uroot -predhat -e 'CREATE DATABASE db2;' # mysql -uroot -predhat db2 < westos.dump
8.网页管理数据库
1)装软件Http,PHP,php-mysql  (phpMyAdmin-3.4.0-all-languages) 2)cd /var/www/html 3)下载解压php压缩包, 4)mv phpMyAdmin-3.4.0-all-languages/   myadmin   5)cd myadmin/ 6)cp config.sample.inc.php  config.inc.php   vim config.inc.php        $cfg['blowfish_secret'] = '';       ==>$cfg['blowfish_secret'] = 'steven';   7)systemctl restart httpd   8)172.252.254.X/myadmin    
数据库备份脚本
#!/bin/bash HELLO=$1.`date +%Y-%m-%d`.sql read -p "please input your  user name :"  NAME read -s -p "please input the user password :" PASSWORD mkdir /mydata  &>/dev/null touch /mydata/$HELLO mysqldump -u$NAME -p$PASSWORD  $1 >/mydata/$HELLO echo -e  "\nThe backup successful!"
  
  


您可能感兴趣的文档:

--结束END--

本文标题: mariadb数据库服务

本文链接: https://www.lsjlt.com/news/40421.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • mariadb数据库服务
    什么是mariadb        MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MyS...
    99+
    2022-10-18
  • mariadb数据库
    ##配置网络 vim/etc/sysconfig/network-scripts/ifcfg-eth0 写网络配置文件 systemctl restart network  重...
    99+
    2022-10-18
  • 3-unit8 Mariadb数据库
    ######unit8数据库#########本单元涵盖的主题:*配置和管理数据库*配置数据库用户和访问权限*备份和恢复数据库######数据库的基本sql语句操作######## 1.下载安装y...
    99+
    2022-10-18
  • Linux_MySQL(mariadb)数据库上(3)
     服务器端命令:       DDL:数据定义语言,主要用于管理数据库组件,例如表、索引、视图、用户、存储过程 &n...
    99+
    2022-10-18
  • Linux_MySQL(mariadb)数据库(2)V1.0
    MySQL AB  --> MySQL       Solaris:二进制版本;  &nb...
    99+
    2022-10-18
  • docker运行mariadb数据库
    安装MariaDB docker pull mariadb 运行MariaDB docker run --name some-mariadb -p 3306:3306 -v /usr/local/docker/mariadb/logs:...
    99+
    2021-04-19
    docker运行mariadb数据库
  • Mysql/MariaDB数据库入门
    内容:1、数据库简介以及mysql/mariadb背景介绍2、数据库的一些名词3、mysql的服务结构4、mysql客户端的使用5、数据类型6、SQL语句介绍7、mysql的事务机制一、数据库简介以及mys...
    99+
    2022-10-18
  • Windows 下安装 MariaDB (mariadb-10.4.13-winx64.zip) 数据库
    官网下载 mariadb-10.4.13-winx64.zip , 并解压 在对应的bin目录下, 执行cmd命令, 以管理员身份运行cmd, 然后执行 mysql_install_db.exe --datadir=D:/mari...
    99+
    2016-08-25
    Windows 下安装 MariaDB (mariadb-10.4.13-winx64.zip) 数据库
  • 关于Linux的mariadb数据库
    目录关于Linux的mariadb数据库一、什么是数据库(DATABASE)二、数据库的分类1、关系型数据库(sql)2、非关系型数据库(nosql)三、DML(data manip...
    99+
    2022-11-12
  • MariaDB数据库的主从配置
    1、前置工作 首先准备两台可以互相ping通的机器,两台机器可以互为主从,示例:10.210.23.77主服务器 183从服务器 2、安装 在两台机器上各自安装数据 解压MariaDB安装包; tar zxvf MariaDB.tgz cd...
    99+
    2023-10-18
    数据库 运维
  • 【基础部分】之数据库 mariadb
    1.数据库的安装yum install mariadb.x86_64 mariadb-server.x86_64 -y关掉防火墙关闭网络端口(禁止外人访问)netstat -antlpe | grep my...
    99+
    2022-10-18
  • RHEL7.2配置安装MariaDB数据库
    MariaDBMariaDB是MySQL的一个分支,从MySQL被甲骨文收购之后开发的一个替代品,目前全部兼容MySQL。MariaDB 是一个采用 Maria 存储引擎的MySQL 分支版本,是由原来 M...
    99+
    2022-10-18
  • mariadb数据库 xtrabackup 备份工具
    XtraBackup备份工具三步骤 1.安装XtraBackup软件包。 2.使用XtraBackup执行完整备份、增量备份。 3.准备数据恢复目录。 需要yum -y install perl-DBD-M...
    99+
    2022-10-18
  • MariaDB、MySQL数据库主从同步
    1、Mysql主从同步异步概念    异步:主服务器写完日志后立即返回同步完成消息,不受从服务器的状态和影响,mysql默认为异步工作模式  &n...
    99+
    2022-10-18
  • 数据库之mariadb整体概述
    一、数据库的安装方式及其安装步骤 1、安装方式 rpm包安装,yum安装,二进制包安装,编译安装   2、安装步骤 (本文是使用二进制包安装)1)下载mariadb相...
    99+
    2022-10-18
  • 【MySQL】数据库审计--MariaDB Audit Plugin
    [root@wallet01 ~]# cd /usr/lib64/mysql/plugin [root@wallet01 plugin]# chmod a+x server_audit.so [root@...
    99+
    2022-10-18
  • 使用PHP连接MariaDB数据库
    MariaDB是一种开源的关系型数据库管理系统,它是MySQL的一个分支。PHP作为一种开源的服务器端脚本语言,被广泛应用于Web开发中。在很多Web开发项目中,需要使用PHP连接到MariaDB数据库,以便在Web应用程序中存储和检索数据...
    99+
    2023-05-17
    PHP mariadb 连接
  • MariaDB Spider数据库分库分表的方法
    本文小编为大家详细介绍“MariaDB Spider数据库分库分表的方法”,内容详细,步骤清晰,细节处理妥当,希望这篇“MariaDB Spider数据库分库分表的方法”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入...
    99+
    2023-06-29
  • CentOS7.X怎么安装MariaDB数据库
    这篇文章主要介绍“CentOS7.X怎么安装MariaDB数据库”,在日常操作中,相信很多人在CentOS7.X怎么安装MariaDB数据库问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望...
    99+
    2022-10-18
  • 如何在Linux中配置MariaDB数据库
    这篇文章将为大家详细讲解有关如何在Linux中配置MariaDB数据库,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。什么是Linux系统Linux是一种免费使用和自由传播的类UNIX操作系统...
    99+
    2023-06-07
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作