欢迎投稿

今日深度:

Mariadb,

Mariadb,


   介绍:MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可MariaDB的目的是完全兼容MySQL,包括API和命令行,是MySQL的代替品。而MariaDB由MySQL的创始人Michael Widenius主导开发,MariaDB的名称来自Michael Widenius的女儿Maria的名字

1)安装

yum search mariadb               
yum install mariadb-server.x86_64 -y

2)登录

systemctl start mariadb      ##开启mariadb的服务
systemctl enable mariadb     ##开机启动
systemctl stop firewalld     ##关闭防火墙

mysql                        ##本机登录
mysql -uroot -h IP           ##远程登录,IP为装有mysql的计算机的IP

mysql_secure_installation            ##设置安全访问,完成后,即可使用密码登录
mysql -uroot -p

3)数据库的管理
1.查询
show database; ##显示数据库列表

use mysql; ##使用数据库
show tables; ##显示表单

desc user; ##查看表格结构

select * from user; ##查询user的数据
select * from user where HOST=’127.0.0.1’
2.创建

create database westos;    ##创建westos的数据库
use westos;                ##使用westos的数据库
create table linux(        ##创建表格
   username varchar(50) not null,
   password varchar(50) not null,
   age varchar(50) );
insert into linux values ('lee','123','20')  ##往表格中插入数据


3.修改

alter table linux rename to message;   ##修改表名
alter table linux add class varchar(50);  ##向表中添加字段
alter table linux add class varchar(50) after password; 
alter table linux drop class;  ##删除表中某字段
update linux set class='linux';  ##修改表中字段的信息
update linux set class='java' where username='lee';

4.备份

mysqldump -uroot -predhat westos > /mnt/westos.sql  ##将数westos的数据库备份到/mnt/下,命名为westos.sql
drop database westos;
mysql -uroot -predhat -e "create database westos;"
mysql -uroot -predhat westos < /mnt/wetsos.sql

5.删除

delete from linux where username='lee' and class='Java';
drop table linux;
drop database WESTOS;

6.数据库密码忘记怎么办?

systemclt stop mariadb
mysqld_safe --skip-grant-tables &
进入数据库更新密码
use mysql
update user set Password=password('redhat') where User='root';
ps aux | grep mysql
kill -9 数据库进程
systemctl restart mariadb


7.授权
授权首先得由接受授权的对象,所以,应该先添加数据库用户

create user lee@localhost idenfified by 'lee';  ##创建用户lee
show grants for lee@localhost; ##查看lee都有哪些权限
例1:给lee用户westos数据库下的所有表的select权限
    grant select on westos.* to lee@localhost;
例2:撤销lee用户在westos数据库下所有表的drop权限
    revoke drop on westos.* from lee@localhost
 flush privileges;   ##重载授权表

8.mysql的图形管理工具

yum install httpd -y      ##安装客户端访问的浏览器
systemctl start httpd
systemctl enable httpd
phpMyAdmin的安装:
下载 --> 解压到Apache的默认发布目录  --> 重命名为:mysqladmin
cd /var/www/html/mysqladmin
cp config.sample.inc.php config.inc.php
less Documentation.txt
vim config.inc.php
systemctl stop firewalld
systemctl disable firewalld
yum install php -y       ##安装php
yum install php-mysql.x86_64
测试:
     firefox 
     http://172.25.254.108/mysqladmin 
     ##使用图形化界面管理Mysql数据库,sql语句会自动生成

www.htsjk.Com true http://www.htsjk.com/mariadb/36673.html NewsArticle Mariadb, 介绍:MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可MariaDB的目的是完全兼容MySQL,包括API和命令行,是MySQL的代替品。而MariaDB由MySQL的创始人...
相关文章
    暂无相关文章
评论暂时关闭