什么是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 mysqlLISTEN     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 currentpassword for the root user.  If you've just installed MariaDB, andyou 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 MariaDBroot 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 anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.

Remove anonymous users? [Y/n]  ... Success!

Normally, root should only be allowed to connect from 'localhost'.  Thisensures 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 canaccess.  This is also intended only for testing, and should be removedbefore 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 farwill take effect immediately.

Reload privilege tables now? [Y/n]  ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDBinstallation 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.数据库基本操作SQLshow 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!"       

mariadb数据库服务相关推荐

  1. MariaDB数据库服务常见操作

    一.初始化mariaDB服务程序: yum install mariadb mariadb-server //安装mariaDB systemctl start mariadb //启动mariadb ...

  2. 基于kali2020环境,熟悉数据库服务的部署及基本验证方法及访问数据库

    1.1 问题 本例要求基于kali2020环境,熟悉数据库服务的部署及基本验证方法,完成下列任务: 1)在kali2020上启用mysql服务,并设置开机自启 2)完成初始安全设置,将管理密码设为12 ...

  3. mac系统装mysql还是mariadb_Mac安装MariaDB数据库

    Mac安装MariaDB数据库 参考资料: 如果你是Mac上的开发者,你可以在OS X上通过Homebrew来简单的获取安装最新稳定版本的MariaDB,接下来我们将一步步的来指导安装MariaDB数 ...

  4. 【MariaDB】浅谈 MariaDB 数据库

    MariaDB简述 1.总述: MariaDB是MySQL数据库的一个分支,使用方法几乎与MySQL完全一致,包括命令.界面.使用等,根据官方介绍,在MariaDB 5.5版本之前,所欲的功能特性完全 ...

  5. Mysql数据库迁移Mariadb完整方案

    Mysql数据库迁移Mariadb方案 一.       文档描述 l  目的:测试window和linux上MariaDB支持性. l  原则:window下保留原有Mysql ,安装MariaDB ...

  6. AWS之EC2搭建WordPress博客

    AWS之搭建WordPress博客 注意:请确定您已经成功完成LAMP架构的搭建; 1.下载并解压WordPress安装包: ①使用wget命令在WordPress官网获取最新安装包: [ec2-us ...

  7. NFS为lamp提供共享存储实践

    本文旨在实现NFS为lamp环境web站点提供共享存储. 1.实验需求 (1)nfs server导出/data/application/web,在目录中提供wordpress; (2)nfs cli ...

  8. Linux三大主流网站构建平台,Linux快速构建LAMP网站平台

    1.1 问题 本例要求基于Linux主机快速构建LAMP动态网站平台,并确保可以支撑PHP应用及数据库,完成下列任务: 1)安装LAMP平台各组件,启动LAMP平台 软件包:httpd.mariadb ...

  9. 一个脚本实现全量增量备份,并推送到远端备份中心服务器

    2019独角兽企业重金招聘Python工程师标准>>> 摘要 由于工作需要,刚好需要这样一个功能的脚本,主要解决: 1. 不想在crontab中调度两条备份任务,一个做全量一个做增量 ...

最新文章

  1. 在?三缺一,来斗个地主——肝个斗地主案例(java)
  2. 【思维导图总结——数据库系统概论】绪论
  3. 第六周作业(sticky
  4. php error 2,一起搞懂PHP的错误和异常(二)
  5. UE满足发射功率要求是指
  6. 一个泛型冒泡排序的实现
  7. 2010.7.29 模式对话框
  8. [C#.NET 拾遗补漏]10:理解 volatile 关键字
  9. 解决高版本SpringBoot整合swagger时启动报错:Failed to start bean ‘documentationPluginsBootstrapper‘ 问题
  10. 02、django中的上下文
  11. MySQL 数据库救火:磁盘爆满了,怎么办?
  12. 【BZOJ2655】calc,dp+拉格朗日插值法
  13. 4400元起!iPhone 12全系售价曝光:标配数据线但无充电器
  14. 简单理解下内存的几大区域
  15. linux 邮件文件名 病毒,linux-qmail 病毒/垃圾邮件处理
  16. 【GLPNet2021】GLOBAL-LOCAL PROPAGATION NETWORK FOR RGB-D SEMANTIC SEGMENTATION
  17. 阿里云短信服务-个人账户测试短信服务
  18. hackinglab.cn 注入关之一
  19. css3渐变—渐变_玩渐变
  20. 快手安全 X 墨菲安全 | 软件供应链安全解决方案完整分享

热门文章

  1. LeetCode--32. 最长有效括号(栈)
  2. php自动验证,ThinkPHP 自动验证及验证规则详解
  3. HTML Img Compression(压缩)
  4. 阿里云镜像下载ubuntu
  5. zabbix服务器与客户端(Linux+Windows)的搭建
  6. [log4j]log4j简单配置
  7. Python2.7编程基础(博主推荐)
  8. DotNet Core 2.0部署后外网IP访问
  9. mysql Error_code: 1593
  10. JAVA编程相关:eclipse如何导入已有工程