美文网首页
Linux云计算学习笔记day46

Linux云计算学习笔记day46

作者: 我要笑 | 来源:发表于2019-06-10 19:42 被阅读0次

    数据库基础操作:

    查看所有数据库

    MariaDB [(none)]> show databases ;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    +--------------------+
    4 rows in set (0.01 sec)
    
    MariaDB [(none)]> #tree 
    ##查看数据库中的表
    MariaDB [(none)]> show tables from mysql; 
        
    #查看user表中的 user和host字段
    MariaDB [(none)]> #select user,host from mysql.user;
    MariaDB [(none)]> #显示出 user和host两个字段  在mysql数据库中 的user表中进行查找
    MariaDB [(none)]> 
    MariaDB [(none)]> select user,host from mysql.user;
    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | 127.0.0.1 |
    | root | ::1       |
    |      | localhost |
    | root | localhost |
    |      | web01     |
    | root | web01     |
    +------+-----------+
    6 rows in set (0.00 sec)             
    

    只显示1条数据

    MariaDB [(none)]> select * from mysql.user limit 1 ;
    MariaDB [(none)]> select * from mysql.user limit 1 \G

    whoami

    select user();

    pwd 显示当前使用的数据库

    select database(); 
    
    MariaDB [(none)]> select user,host from mysql.user ;
    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | 127.0.0.1 |
    | root | ::1       |
    |      | localhost |
    | root | localhost |
    |      | web01     |
    | root | web01     |
    +------+-----------+
    6 rows in set (0.00 sec)
    
    MariaDB [(none)]> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    MariaDB [mysql]> select user,host from  user ;
    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | 127.0.0.1 |
    | root | ::1       |
    |      | localhost |
    | root | localhost |
    |      | web01     |
    | root | web01     |
    +------+-----------+
    6 rows in set (0.00 sec)
    
    
    mysql  -uroot -p  -h172.16.1.7
    mysql  -uroot -p  
    
    
    MariaDB [(none)]> drop user ''@'localhost'; 
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> drop user ''@'web01'; 
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> 
    MariaDB [(none)]> select user,host from  mysql.user ;
    +-----------+------------+
    | user      | host       |
    +-----------+------------+
    | root      | 127.0.0.1  |
    | wordpress | 172.16.1.% |
    | root      | ::1        |
    | root      | localhost  |
    | wordpress | localhost  |
    | root      | web01      |
    +-----------+------------+
    6 rows in set (0.00 sec)
    
    MariaDB [(none)]> 
    MariaDB [(none)]> flush privileges;
    
    [root@web01 ~]# mysqldump -uroot -p -A  >/root/all.sql 
    Enter password: 
    
    
     mysqldump -uroot -p -A  >/root/all.sql 
     mysql -uroot -p     </root/all.sql 
    
    [root@web01 ~]# mysqldump -uroot -p -A  |gzip  >/root/all-gzip.sql.gz
    Enter password: 
    [root@web01 ~]# ll /root/all-gzip.sql.gz 
    -rw-r--r-- 1 root root 139656 Jun 10 11:21 /root/all-gzip.sql.gz
    [root@web01 ~]# ll -h /root/all-gzip.sql.gz 
    -rw-r--r-- 1 root root 137K Jun 10 11:21 /root/all-gzip.sql.gz
    

    相关文章

      网友评论

          本文标题:Linux云计算学习笔记day46

          本文链接:https://www.haomeiwen.com/subject/kxmtfctx.html