maiadb

来源:互联网 发布:协同网络办公系统 编辑:程序博客网 时间:2024/06/08 07:23

1.安装服务

yum install mariadb-server -y

systemctl  start mariadb             #启动服务

/etc/my.cnf                                 #mariadb的主配置文件

vim /etc/my.cnf     

10  skip-networking=1               #禁止网络用户访问

systemctl restart  mariadb

mysql_secure_installation        #对mariadb软件进行设置


2.登陆

mysql  -uroot  -pwestos

3.查询

show databases;                #显示数据库

use  mysql;                        #进入mysql库

show tables;                      #显示当前库中表的名称

select * from user;             #查询user表中的所有内容(*可以用表中的任意字段代替

desc user;                        #查询user表的结构


4.数据库表的建立

create  database  westos;           #建立westos库

create  table  linux(                    #建立linux表,表结构有两列

username  varchar(15) not null,

password  varchar(15)  not null

);

insert  into linux  values ('user1','password1');    #向表中插入信息

insert  into linux  values ('user2',password('123') );  #password字段是进行加密过的

5.更新数据库信息

update  linux  set  password=password('password2') where username='user1';     #更新user1的密码

delete  from  linux  where username='user1';   #删除user1的信息

alter  table  linux  add  age  varchar(4);            #添加age字段到linux表的最后一列

alter  table  linux  add  age  varchar(5)  after name;    #添加age字段在name字段之后

alter  table  linux  drop  age;                          #删除age字段

6.删除数据库

drop  table  linux;                #删除linux表

drop  database  westos;       #删除westos库

7.数据库的备份

mysqldump  -uroot  -pwestos  --all-database                    #备份所有表中的信息

mysqldump  -uroot  -pwestos  --all-database   --no-data      #备份所有表,但不备份数据

mysqldump  -uroot  -pwestos  westos                           #备份westos库

mysqldump  -uroot  -pwestos  westos > /mnt/westos.sql    #备份westos库并把数据保存到westos.sql中

mysqldump  -uroot  -pwestos  westos  linux > /mnt/linux.sql  #备份westos库中的linux表

mysql  -uroot  -pwestos  -e  "drop  database  westos;"   #删除westos库

mysql  -uroot  -pwestos  -e  "create database  westos;"   #建立westos库

mysql  -uroot  -pwestos   westos < /mnt/westos.sql       #把备份的数据导入westos库中


8.用户授权

create  user  chen@localhost  identified  by  'chen';    #建立用户chen,只能通过本机登陆

create  user  chen@'%'  identified  by  'chen';   #建立用户,此用户可通过网络登陆

grant  insert,update,delete,select  on  westos.*  to  chen@localhost;   #用户授权


grant  select  on  westos.*  to  chen@'%';

show  grants  for  chen@'%';           #查看用户授权

show  grants  for  chen@localhost;   

revoke  delete  on  westos.*   from  chen@localhost;      #去除用户权力

drop  user  chen@'%';                      #删除用户

授权后

9.密码修改

mysqladmin  -uroot  -pwestos  password   chen    #密码记得时修改超级用户密码

mysqld_safe  --skip-grant-table &              #开启mysql登陆接口并忽略授权表

mysql                                   #不用密码直接登陆

update  mysql.user   set  Password=password('1234')  where  User='root';  #更改超级用户密码

ps  aux |  grep  mysql           #过滤mysql的所有进程并结束这些进程

kill  -9  mysqlpid

systemctl start  mariadb                     #重启mysql

mysql  -uroot   -p1234                   #进行登陆测试

网页版mariadb

1.安装

yum  install  httpd  php  php-mysql  -y

systemctl start  httpd

systemctl  enable httpd

systemctl stop firewalld

systemctl  disable  firewalld

需要下载

phpMyAdmin-3.4.0-all-languages.tar.bz2 

tar  jxf  phpMyAdmin-3.4.0-all-languages.tar.bz2  -C /var/www/html

cd  /var/www/html/

mv  phpMyAdmin-3.4.0-all-languages.tar.bz2/  mysqladmin

cd  mysqladmin

cp -p  config.sample.inc.php  config.inc.php

vim config.inc.php

17 $cfg['blowfish_secret'] = 'mysql';

systemctl  restart   httpd

测试

访问 172.25.254.118/mysqladmin


原创粉丝点击