温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

maridb

发布时间:2020-08-06 10:38:25 来源:网络 阅读:628 作者:漂浮的天堂 栏目:数据库

Maridb

yum intall mariadb-server -y  ##安装mariadb服务

systemctl start mariadb    ##开启服务



vim /etc/my.cnf     ##修改配置文件

maridb

 systemctl  restart  mariadb  #重启服务


 mysql_secure_installtion   ##mysql加密


Enter current password for root (enter for none):   ##数据库原始密码,直接回车

Change the root password? [Y/n] y  ##是否设定数据库root密码

New password:               ##输入密码

Re-enter new password:         ##重复密码

Remove anonymous users? [Y/n] y  ##是否删除匿名用户访问权限

Disallow root login remotely? [Y/n] y  ##是否禁止超级用户远程登录

Remove test database and access to it? [Y/n] y   ##是否删除测试数据

Reload privilege tables now? [Y/n] y     ##重新加载服务

maridb

数据库的基本sql语句操作

   (1)登录

    mysql -uroot -p    ##-u代表用户  -p密码

maridb

    (2)查询

    show databases;     ##显示数据库

    use mysql;        ##进入mysql库

maridb

     show tables;       ##显示数据库里表的名称


     select * from user;    ##查询user表中所有内容

maridb

     desc linux;          ##查询表的结构 (显示表头)

maridb

   (3)数据库的建立

     create database westos;     ##建立westos库

    create table linux(        ##建立Linux表,并且有username和password两个字段

maridb

     username varchar(15) not null,

     password varchar(15) not null

     ); 

maridb

     insert into linux values ('user1','123')   ##给Linux表里写入内容

maridb

   (4)数据库的更新

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

    update linux set password=password('456') where (username='user2' or username='user3';  ##更新user2和user3密码

maridb

maridb

maridb

    delete from linux where where username='user1';  ##删除user1密码

maridb

alter table linux add age varchar(4);     ##在Linux表最后添加age列

alter table linux add year varchar(4)after age ##在age字段后添加year字段

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

maridb

   (5)删除数据库

     drop table linux    ##删除Linux表

maridb

     drop database westos   ##删除westos库


   (6)数据库的备份

     mysqldump -u root -p123 --all -database  ##备份表中所有数据

maridb

     mysqldump -u root -p123 --all -database --no-data  ##备份所有表,不备份数据

maridb

     mysqldump -u root -p123 westos    ##备份westos库

     mysqldump -u root -p123 westos > /mnt/westos.sql  ##备份westos库保存到westos.sql

     mysqldump -u root -p123 westos linux > /mnt/linux.sql  ##备份westos库中的Linux表

maridb

     mysql -u root -p123 -e "create database westoss;"  ##建立westos库

     mysql -u root -p123 westos <  /mnt/linux.sql  ##导入数据到westos库

maridb



   (7)用户授权

    create user ggg@localhost identified by 'ggg';  ##创建用户ggg,只能通过本机登录

    create user ggg@'%' identified by 'ggg';     ##创建用户ggg,只能通过网络登录

    grant insert,update,delete,select on westos.linux to ggg@localhost  ##用户授权

maridb

     revoke delete on westos.linux from ggg@localhost   ##删除用户授权

    drop user ggg@'%'   ##删除用户

maridb

    (8)修改密码

      mysqladmin -uroot -predhat password 123

     mysqld_safe --skip-grant-table &  ##开启MySQL登录接口忽略授权表

     mysql               ##不要密码登录


     update mysql.user set Password=password('123') where User='root'  ##更新root密码

     ps aux | grep mysql ##过滤mysql进程并结束

     kill -9   mysqlpid    

     systemctl start maraidb   ##重启MySQL

maridb

    3.数据库网页管理工具

     yum install httpd php phy-mysql -y  ##安装服务

   systemctl start httpd

   systemctl enable httpd

   systemctl stop firewalld

   systemctl disable firewall

  

   tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html ##解压文件到指定目录

maridb

   mv  phpMyAdmin-3.4.0-all-languages/ mysqladim  ##重命名文件


   cd mysqladim

   cp -p config.sample.inc.php  config.inc.php  ##复制模板

   vim  config.inc.php  ##编辑配置文件

修改配置文件内容

maridb

   systemctl restart httpd  

访问http://172.25.254.117/mysqladmin

ctrl+shift+delete   ##清除缓存

maridb

maridb

maridb

maridb

maridb


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI