數據庫概述、部署MySQL服務、必備命令、密碼管理、安裝圖形軟件、SELECT語法 、篩選條件

Top

NSD DBA DAY01

  1. 案例1:構建MySQL服務器
  2. 案例2:密碼管理
  3. 案例3:安裝圖形軟件
  4. 案例4:篩選條件

1 案例1:構建MySQL服務器

1.1 問題

  1. 在IP地址192.168.88.50主機和192.168.88.51主機上部署mysql服務
  2. 練習必備命令的使用

1.2 方案

準備2臺虛擬機,要求如下:

表-1

?

配置yum源、關閉selinux和防火墻,如果忘記了請自行補習前邊課程的知識或查看今天講課的PPT,謝謝!!!

1.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:安裝軟件

命令操作如下所示:

mysql-server 提供服務軟件

mysql 提供命令軟件

 
  1. [root@mysql50 ~]# yum -y install mysql-server mysql //安裝提供服務和命令軟件
  2. //軟件已安裝
  3. [root@mysql50 ~]# rpm -q mysql-server mysql
  4. mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64
  5. mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64
  6. [root@mysql50 ~]#
  7. [root@mysql50 ~]# rpm -qi mysql-server //查看軟件信息
  8. Name : mysql-server
  9. Version : 8.0.26
  10. Release : 1.module+el8.4.0+652+6de068a7
  11. Architecture: x86_64
  12. Install Date: 2023年03月13日 星期一 12時09分38秒
  13. Group : Unspecified
  14. Size : 126674945
  15. License : GPLv2 with exceptions and LGPLv2 and BSD
  16. Signature : RSA/SHA256, 2021年09月22日 星期三 07時27分14秒, Key ID 15af5dac6d745a60
  17. Source RPM : mysql-8.0.26-1.module+el8.4.0+652+6de068a7.src.rpm
  18. Build Date : 2021年09月22日 星期三 07時06分32秒
  19. Build Host : ord1-prod-x86build005.svc.aws.rockylinux.org
  20. Relocations : (not relocatable)
  21. Packager : infrastructure@rockylinux.org
  22. Vendor : Rocky
  23. URL : http://www.mysql.com
  24. Summary : The MySQL server and related files
  25. Description :
  26. MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
  27. client/server implementation consisting of a server daemon (mysqld)
  28. and many different client programs and libraries. This package contains
  29. the MySQL server and some accompanying files and directories.
  30. [root@mysql50 ~]# systemctl start mysqld //啟動服務
  31. [root@mysql50 ~]# systemctl enable mysqld //開機運行
  32. [root@mysql50 ~]# systemctl enable mysqld //設置服務開機運行
  33. Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

步驟二:查看端口號和進程名

命令操作如下所示:

 
  1. [root@mysql50 ~]# ps -C mysqld //查看進程
  2. PID TTY TIME CMD
  3. 21912 ? 00:00:00 mysqld
  4. [root@mysql50 ~]#
  5. [root@mysql50 ~]# ss -utnlp | grep 3306 查看端口
  6. tcp LISTEN 0 70 *:33060 *:* users:(("mysqld",pid=21912,fd=22))
  7. tcp LISTEN 0 128 *:3306 *:* users:(("mysqld",pid=21912,fd=25))
  8. [root@mysql50 ~]#
  9. [root@mysql50 ~]# netstat -utnlp | grep mysqld //僅查看mysqld進程
  10. tcp6 0 0 :::33060 :::* LISTEN 21912/mysqld
  11. tcp6 0 0 :::3306 :::* LISTEN 21912/mysqld
  12. [root@mysql50 ~]#

說明:

MySQL 8中的3306端口是MySQL服務默認使用的端口,主要用于建立客戶端與MySQL服務器之間的連接。

MySQL 8中的33060端口是MySQL Shell默認使用的管理端口,主要用于執行各種數據庫管理任務。遠程管理MySQL服務器:使用MySQL Shell連接到MySQL服務,并在遠程管理控制臺上執行各種數據庫管理操作,例如創建、刪除、備份和恢復數據庫等。

步驟三:連接服務。

說明: 數據庫管理員本機登陸默認沒有密碼

命令操作如下所示:

 
  1. [root@mysql50 ~]# mysql //連接服務
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 8
  4. Server version: 8.0.26 Source distribution
  5. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> 登陸后的提示符
  11. mysql> exit //斷開連接
  12. Bye
  13. [root@mysql50 ~]#

步驟四:配置第2臺數據庫服務器MySQL51。

命令操作如下所示:

 
  1. [root@mysql51 ~]# yum -y install mysql-server mysql
  2. [root@mysql51 ~]# systemctl start mysqld
  3. [root@mysql51 ~]# systemctl enable mysqld
  4. [root@mysql51 ~]# mysql
  5. mysql> exit
  6. Bye
  7. [root@mysql51 ~]#

步驟五:練習必備命令的使用(在mysql50主機完成練習)

命令操作如下所示:

 
  1. mysql> select version() ; //查看數據庫軟件版本
  2. +-----------+
  3. | version() |
  4. +-----------+
  5. | 8.0.26 |
  6. +-----------+
  7. 1 row in set (0.00 sec)
  8. mysql> select user() ; //查看登陸的用戶和客戶端地址
  9. +----------------+
  10. | user() |
  11. +----------------+
  12. | root@localhost | 管理員root本機登陸
  13. +----------------+
  14. 1 row in set (0.00 sec)
  15. mysql> show databases; //查看已有的庫
  16. +--------------------+
  17. | Database |
  18. +--------------------+
  19. | information_schema |
  20. | mysql |
  21. | performance_schema |
  22. | sys |
  23. +--------------------+
  24. 4 rows in set (0.00 sec)
  25. mysql>

說明:

默認4個庫 不可以刪除,存儲的是 服務運行時加載的不同功能的程序和數據。

information_schema:是MySQL數據庫提供的一個虛擬的數據庫,存儲了MySQL數據庫中的相關信息,比如數據庫、表、列、索引、權限、角色等信息。它并不存儲實際的數據,而是提供了一些視圖和存儲過程,用于查詢和管理數據庫的元數據信息。

mysql:存儲了MySQL服務器的系統配置、用戶、賬號和權限信息等。它是MySQL數據庫最基本的庫,存儲了MySQL服務器的核心信息。

performance_schema:存儲了MySQL數據庫的性能指標、事件和統計信息等數據,可以用于性能分析和優化。

sys:是MySQL 8.0引入的一個新庫,它基于information_schema和performance_schema視圖,提供了更方便、更直觀的方式來查詢和管理MySQL數據庫的元數據和性能數據。

 
  1. mysql> select database(); //查看當前在那個庫里 null 表示沒有在任何庫里
  2. +------------+
  3. | database() |
  4. +------------+
  5. | NULL |
  6. +------------+
  7. 1 row in set (0.00 sec)
  8. mysql> use mysql ; //切換到mysql庫
  9. mysql> select database(); // 再次顯示所在的庫
  10. +------------+
  11. | database() |
  12. +------------+
  13. | mysql |
  14. +------------+
  15. 1 row in set (0.00 sec)
  16. mysql> show tables; //顯示庫里已有的表
  17. +------------------------------------------------------+
  18. | Tables_in_mysql |
  19. +------------------------------------------------------+
  20. | columns_priv |
  21. | component |
  22. | db |
  23. | default_roles |
  24. | engine_cost |
  25. | func |
  26. | general_log |
  27. | global_grants |
  28. | gtid_executed |
  29. | help_category |
  30. | help_keyword |
  31. | help_relation |
  32. | help_topic |
  33. | innodb_index_stats |
  34. | innodb_table_stats |
  35. | password_history |
  36. | plugin |
  37. | procs_priv |
  38. | proxies_priv |
  39. | replication_asynchronous_connection_failover |
  40. | replication_asynchronous_connection_failover_managed |
  41. | replication_group_configuration_version |
  42. | replication_group_member_actions |
  43. | role_edges |
  44. | server_cost |
  45. | servers |
  46. | slave_master_info |
  47. | slave_relay_log_info |
  48. | slave_worker_info |
  49. | slow_log |
  50. | tables_priv |
  51. | time_zone |
  52. | time_zone_leap_second |
  53. | time_zone_name |
  54. | time_zone_transition |
  55. | time_zone_transition_type |
  56. | user |
  57. +------------------------------------------------------+
  58. 37 rows in set (0.00 sec)
  59. mysql> exit ; 斷開連接
  60. Bye
  61. [root@mysql50 ~]#

2 案例2:密碼管理

2.1 問題

1) 在192.168.88.50主機做如下練習:

  1. 設置root密碼為tarena
  2. 修改root密碼為123qqq…A
  3. 破解root密碼為NSD2023…a

2.2 步驟

實現此案例需要按照如下步驟進行。

步驟一:設置root密碼為tarena

命令操作如下所示:

2行輸出是警告而已不用關心

 
  1. [root@mysql50 ~]# mysqladmin -uroot -p password "tarena"
  2. Enter password: //敲回車
  3. mysqladmin: [Warning] Using a password on the command line interface can be insecure.
  4. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
  5. [root@mysql50 ~]# mysql //無密碼連接被拒絕
  6. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  7. [root@mysql50 ~]#
  8. [root@mysql50 ~]# mysql -uroot –ptarena //連接時輸入密碼
  9. mysql: [Warning] Using a password on the command line interface can be insecure.
  10. Welcome to the MySQL monitor. Commands end with ; or \g.
  11. Your MySQL connection id is 14
  12. Server version: 8.0.26 Source distribution
  13. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  14. Oracle is a registered trademark of Oracle Corporation and/or its
  15. affiliates. Other names may be trademarks of their respective
  16. owners.
  17. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  18. mysql> 登陸成功

步驟二:修改root密碼為123qqq…A

命令操作如下所示:

 
  1. [root@mysql50 ~]# mysqladmin -uroot -ptarena password "123qqq...A" //修改密碼
  2. mysqladmin: [Warning] Using a password on the command line interface can be insecure.
  3. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
  4. [root@mysql50 ~]# mysql -uroot –ptarena //舊密碼無法登陸
  5. mysql: [Warning] Using a password on the command line interface can be insecure.
  6. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  7. [root@mysql50 ~]# mysql -uroot -p123qqq...A //新密碼登陸
  8. mysql: [Warning] Using a password on the command line interface can be insecure.
  9. Welcome to the MySQL monitor. Commands end with ; or \g.
  10. Your MySQL connection id is 18
  11. Server version: 8.0.26 Source distribution
  12. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  13. Oracle is a registered trademark of Oracle Corporation and/or its
  14. affiliates. Other names may be trademarks of their respective
  15. owners.
  16. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  17. mysql> 登陸成功

步驟三:破解root密碼為NSD2023…a

說明:在mysql50主機做此練習

命令操作如下所示:

 
  1. [root@mysql50 ~]# mysql -uroot -pNSD2023...a //破解前登陸失敗
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  4. [root@mysql50 ~]# vim /etc/my.cnf.d/mysql-server.cnf //修改主配置文件
  5. [mysqld]
  6. skip-grant-tables //手動添加此行 作用登陸時不驗證密碼
  7. :wq
  8. [root@mysql50 ~]# systemctl restart mysqld //重啟服務 作用讓服務以新配置運行
  9. [root@mysql50 ~]# mysql //連接服務
  10. Welcome to the MySQL monitor. Commands end with ; or \g.
  11. Your MySQL connection id is 7
  12. Server version: 8.0.26 Source distribution
  13. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  14. Oracle is a registered trademark of Oracle Corporation and/or its
  15. affiliates. Other names may be trademarks of their respective
  16. owners.
  17. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  18. //把mysql庫下user表中 用戶root的密碼設置為無;
  19. mysql> update mysql.user set authentication_string="" where user="root";
  20. Query OK, 1 row affected (0.05 sec)
  21. Rows matched: 1 Changed: 1 Warnings: 0
  22. mysql> exit; 斷開連接
  23. Bye
  24. [root@mysql50 ~]# vim /etc/my.cnf.d/mysql-server.cnf 編輯配置文件
  25. [mysqld]
  26. #skip-grant-tables //注釋添加的行
  27. :wq
  28. [root@mysql50 ~]# systemctl restart mysqld //重啟服務 作用讓注釋生效
  29. [root@localhost ~]# mysql 無密碼登陸
  30. Welcome to the MySQL monitor. Commands end with ; or \g.
  31. Your MySQL connection id is 8
  32. Server version: 8.0.26 Source distribution
  33. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  34. Oracle is a registered trademark of Oracle Corporation and/or its
  35. affiliates. Other names may be trademarks of their respective
  36. owners.
  37. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  38. //設置root用戶本機登陸密碼
  39. mysql> alter user root@"localhost" identified by "NSD2023...a";
  40. Query OK, 0 rows affected (0.00 sec)
  41. mysql> exit 斷開連接
  42. Bye
  43. [root@localhost ~]# mysql 不輸密碼無法登陸
  44. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  45. [root@localhost ~]# mysql -uroot -pNSD2023...a 使用破解的密碼登陸
  46. mysql: [Warning] Using a password on the command line interface can be insecure.
  47. Welcome to the MySQL monitor. Commands end with ; or \g.
  48. Your MySQL connection id is 10
  49. Server version: 8.0.26 Source distribution
  50. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  51. Oracle is a registered trademark of Oracle Corporation and/or its
  52. affiliates. Other names may be trademarks of their respective
  53. owners.
  54. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  55. mysql>
  56. mysql> 登陸成功
  57. mysql> show databases; 查看已有的庫
  58. +--------------------+
  59. | Database |
  60. +--------------------+
  61. | information_schema |
  62. | mysql |
  63. | performance_schema |
  64. | sys |
  65. +--------------------+
  66. 4 rows in set (0.01 sec)

3 案例3:安裝圖形軟件

3.1 問題

  • 在IP地址192.168.88.50主機安裝phpmyadmin軟件
  • 客戶端通過訪問phpmyadmin軟件管理數據庫

3.2 方案

把用到的軟件拷貝的虛擬機mysql50里

在mysql50主機,首先配置運行環境LNP,然后安裝phpmyadmin軟件,最后打開真機的瀏覽器輸入phpmyadmin的網址訪問。

3.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:部署運行環境LNP

命令操作如下所示:

 
  1. gcc 源碼包編譯工具
  2. unzip 提供解壓.zip 壓縮包命令
  3. make 源碼軟件編譯命令
  4. pcre-devel 支持正則表達式
  5. zlib-devel 提供數據壓縮命令
  6. [root@mysql50 ~]# yum -y install gcc unzip make pcre-devel zlib-devel //安裝依賴
  7. [root@mysql50 ~]# tar -xf nginx-1.22.1.tar.gz //解壓源碼
  8. [root@mysql50 ~]# cd nginx-1.22.1 //進源碼目錄
  9. [root@mysql50 nginx-1.22.1]# ./configure //配置
  10. [root@mysql50 nginx-1.22.1]# make && make install //編譯并安裝
  11. [root@mysql50 nginx-1.22.1]# ls /usr/local/nginx/ //查看安裝目錄
  12. conf html logs sbin
  13. [root@mysql50 nginx-1.22.1]# vim /usr/local/nginx/conf/nginx.conf //修改主配置文件
  14. 43 location / {
  15. 44 root html;
  16. 45 index index.php index.html index.htm; //添加php首頁名
  17. 46 }
  18. 65 location ~ \.php$ { //訪問.php的請求轉給本機的9000端口
  19. 66 root html;
  20. 67 fastcgi_pass 127.0.0.1:9000;
  21. 68 fastcgi_index index.php;
  22. 69 #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  23. 70 include fastcgi.conf; //保存nginx變量文件
  24. 71 }
  25. :wq
  26. [root@mysql50 nginx-1.22.1]# /usr/local/nginx/sbin/nginx //啟動服務
  27. [root@mysql50 nginx-1.22.1]# netstat -utnlp | grep 80 //查看端口
  28. tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 42182/nginx: master
  29. [root@mysql50 nginx-1.22.1]#
  30. php 解釋php代碼
  31. php-devel php擴展包
  32. php-mysqlnd 連接mysql命令包
  33. php-json 支持json代碼
  34. php-fpm 提供fpm服務
  35. [root@mysql50 ~]# yum -y install php php-devel php-mysqlnd php-json php-fpm //安裝php軟件
  36. [root@mysql50 ~]# vim /etc/php-fpm.d/www.conf //修改主配置文件
  37. 38 ;listen = /run/php-fpm/www.sock
  38. 39 listen = 127.0.0.1:9000 //非socket方式運行,不是必須的
  39. :wq
  40. [root@mysql50 ~]# systemctl start php-fpm //啟動服務
  41. [root@mysql50 ~]# netstat -utnlp | grep 9000 //查看端口
  42. tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 67251/php-fpm: mast
  43. [root@mysql50 ~]#
  44. [root@mysql50 ~]# vim /usr/local/nginx/html/test.php //編寫php腳本
  45. <?php
  46. $name = "plj" ;
  47. echo $name ;
  48. echo "\n" ;
  49. ?>
  50. :wq
  51. [root@mysql50 ~]# curl http://localhost/test.php //訪問腳本
  52. plj
  53. [root@mysql50 ~]#

步驟二:安裝phpmyadmin軟件

命令操作如下所示:

 
  1. [root@mysql50 ~]# unzip phpMyAdmin-5.2.1-all-languages.zip //解壓
  2. [root@mysql50 ~]# mv phpMyAdmin-5.2.1-all-languages /usr/local/nginx/html/phpmyadmin //移動并改名 ,為了便于訪問
  3. [root@mysql50 ~]# cd /usr/local/nginx/html/phpmyadmin/ //進軟件目錄
  4. [root@mysql50 phpmyadmin]# cp config.sample.inc.php config.inc.php //創建主配置文件
  5. [root@mysql50 phpmyadmin]# vim config.inc.php //修改主配置文件
  6. //定義cookies驗證碼
  7. 16 $cfg['blowfish_secret'] = 'plj123'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
  8. //管理本機的數據庫服務
  9. 30 $cfg['Servers'][$i]['host'] = 'localhost';
  10. :wq
  11. [root@mysql50 phpmyadmin]# setenforce 0 //關閉selinux
  12. [root@mysql50 phpmyadmin]# systemctl stop firewalld //關閉防火墻

步驟三:客戶端訪問

命令操作如下所示:

 
  1. http://192.168.88.50/phpmyadmin 打開瀏覽器輸入此網址 效果如圖-1所示

?

圖-1

說明:輸入數據庫管理員root 和 密碼 成功后如圖-2所示

?

4 案例4:篩選條件

4.1 問題

  1. 準備練習環境
  2. 練習數值比較
  3. 練習范圍匹配
  4. 練習模糊匹配
  5. 練習正則匹配
  6. 練習邏輯比較
  7. 練習字符比較/空/非空
  8. 練習別名/去重/合并

4.2 方案

拷貝tarena.sql文件到mysql50主機里,然后使用tarena.sql創建練習使用的數據。

4.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:準備練習環境

 
  1. //拷貝tarena.sql 拷貝到 mysql50主機的/root 下
  2. [openeuler@server1 ~]$ scp /linux-soft/s3/tarena.sql root@192.168.88.50:/root/
  3. root@192.168.88.50's password:
  4. tarena.sql 100% 284KB 171.9MB/s 00:00
  5. //連接mysql50主機
  6. [openeuler@server1 ~]$ ssh root@192.168.88.50
  7. root@192.168.88.50's password:
  8. Last login: Tue May 23 10:59:57 2023 from 192.168.88.254
  9. //恢復數據
  10. [root@mysql50 ~]# mysql -uroot -pNSD2023...a < /root/tarena.sql
  11. mysql: [Warning] Using a password on the command line interface can be insecure.
  12. //連接服務
  13. [root@mysql50 ~]# mysql -uroot -pNSD2023...a
  14. mysql> show databases; //查看庫
  15. +--------------------+
  16. | Database |
  17. +--------------------+
  18. | information_schema |
  19. | mysql |
  20. | performance_schema |
  21. | sys |
  22. | tarena | 恢復的庫
  23. +--------------------+
  24. 5 rows in set (0.00 sec)
  25. mysql> use tarena; //進入庫
  26. Reading table information for completion of table and column names
  27. You can turn off this feature to get a quicker startup with -A
  28. Database changed
  29. mysql> show tables; //查看表
  30. +------------------+
  31. | Tables_in_tarena |
  32. +------------------+
  33. | departments | 部門表
  34. | employees | 員工表
  35. | salary | 工資表
  36. | user | 用戶表
  37. +------------------+
  38. 4 rows in set (0.00 sec)

使用user 表做查詢練習

user表里存儲的是 系統用戶信息 就是 /etc/passwd 文件的內容

 
  1. mysql> desc tarena.user; //查看表頭
  2. +----------+-------------+------+-----+---------+----------------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +----------+-------------+------+-----+---------+----------------+
  5. | id | int(11) | NO | PRI | NULL | auto_increment |行號
  6. | name | char(20) | YES | | NULL | |用戶名
  7. | password | char(1) | YES | | NULL | |密碼占位符
  8. | uid | int(11) | YES | | NULL | | uid號
  9. | gid | int(11) | YES | | NULL | | gid號
  10. | comment | varchar(50) | YES | | NULL | | 描述信息
  11. | homedir | varchar(80) | YES | | NULL | | 家目錄
  12. | shell | char(30) | YES | | NULL | | 解釋器
  13. +----------+-------------+------+-----+---------+----------------+
  14. 8 rows in set (0.00 sec)

select命令格式演示

語法格式1 SELECT 字段列表 FROM 庫名.表名;

語法格式2 SELECT 字段列表 FROM 庫名.表名 where 篩選條件;

 
  1. mysql> select name from tarena.user;????????//查看一個表頭
  2. mysql> select name ,uid from tarena.user;????//查看多個表頭
  3. mysql> select * from tarena.user;????????//查看所有表頭

加篩選條件

 
  1. mysql> select * from tarena.user where name = “root”;????????//查找root用戶信息
  2. +----+------+----------+------+------+---------+---------+-----------+
  3. | id | name | password | uid | gid | comment | homedir | shell |
  4. +----+------+----------+------+------+---------+---------+-----------+
  5. | 1 | root | x | 0 | 0 | root | /root | /bin/bash |
  6. +----+------+----------+------+------+---------+---------+-----------+
  7. 1 row in set (0.00 sec)
  8. mysql>
  9. mysql> select * from tarena.user where id = 2 ;????????//查找第2行用戶信息
  10. +----+------+----------+------+------+---------+---------+--------------+
  11. | id | name | password | uid | gid | comment | homedir | shell |
  12. +----+------+----------+------+------+---------+---------+--------------+
  13. | 2 | bin | x | 1 | 1 | bin | /bin | /sbin/nologin |
  14. +----+------+----------+------+------+---------+---------+--------------+
  15. 1 row in set (0.00 sec)

步驟二:練習數值比較

比較符號:

= != > >= < <=

相等 不相等 大于 大于等于 小于 小于等于

符號兩邊要是數字或數值類型的表頭 符號左邊與符號右邊做比較

 
  1. //查看第3行的行號、用戶名、uid、gid 四個表頭的值
  2. mysql> select id,name,uid,gid from tarena.user where id = 3;
  3. +----+--------+------+------+
  4. | id | name | uid | gid |
  5. +----+--------+------+------+
  6. | 3 | daemon | 2 | 2 |
  7. +----+--------+------+------+
  8. 1 row in set (0.00 sec)
  9. //查看前2行的行號用戶名、uid、gid 四個表頭的值
  10. mysql> select id,name,uid,gid from tarena.user where id < 3;
  11. +----+------+------+------+
  12. | id | name | uid | gid |
  13. +----+------+------+------+
  14. | 1 | root | 0 | 0 |
  15. | 2 | bin | 1 | 1 |
  16. +----+------+------+------+
  17. 2 rows in set (0.00 sec)
  18. //查看前3行的行號、用戶名、uid、gid 四個表頭的值
  19. mysql> select id,name,uid,gid from tarena.user where id <= 3;
  20. +----+--------+------+------+
  21. | id | name | uid | gid |
  22. +----+--------+------+------+
  23. | 1 | root | 0 | 0 |
  24. | 2 | bin | 1 | 1 |
  25. | 3 | daemon | 2 | 2 |
  26. +----+--------+------+------+
  27. 3 rows in set (0.00 sec)
  28. //查看前uid號大于6000的行號、用戶名、uid、gid 四個表頭的值
  29. mysql> select id,name,uid,gid from tarena.user where uid > 6000;
  30. +----+-----------+-------+-------+
  31. | id | name | uid | gid |
  32. +----+-----------+-------+-------+
  33. | 22 | nfsnobody | 65534 | 65534 |
  34. +----+-----------+-------+-------+
  35. 1 row in set (0.00 sec)
  36. //查看前uid號大于等于1000的行號、用戶名、uid、gid 四個表頭的值
  37. mysql> select id,name,uid,gid from tarena.user where uid >= 1000;
  38. +----+-----------+-------+-------+
  39. | id | name | uid | gid |
  40. +----+-----------+-------+-------+
  41. | 22 | nfsnobody | 65534 | 65534 |
  42. | 24 | plj | 1000 | 1000 |
  43. +----+-----------+-------+-------+
  44. 2 rows in set (0.00 sec)
  45. //查看uid號和gid號相同的行 僅顯示行號、用戶名、uid、gid 四個表頭的值
  46. mysql> select id,name,uid,gid from tarena.user where uid = gid;
  47. +----+-----------------+-------+-------+
  48. | id | name | uid | gid |
  49. +----+-----------------+-------+-------+
  50. | 1 | root | 0 | 0 |
  51. | 2 | bin | 1 | 1 |
  52. | 3 | daemon | 2 | 2 |
  53. | 13 | nobody | 99 | 99 |
  54. | 14 | systemd-network | 192 | 192 |
  55. | 15 | dbus | 81 | 81 |
  56. | 17 | sshd | 74 | 74 |
  57. | 18 | postfix | 89 | 89 |
  58. | 20 | rpc | 32 | 32 |
  59. | 21 | rpcuser | 29 | 29 |
  60. | 22 | nfsnobody | 65534 | 65534 |
  61. | 23 | haproxy | 188 | 188 |
  62. | 24 | plj | 1000 | 1000 |
  63. | 25 | apache | 48 | 48 |
  64. | 26 | mysql | 27 | 27 |
  65. +----+-----------------+-------+-------+
  66. 15 rows in set (0.00 sec)
  67. //查看uid號和gid號不一樣的行 僅顯示行號、用戶名、uid、gid 四個表頭的值
  68. mysql> select id,name,uid,gid from tarena.user where uid != gid;
  69. +----+----------+------+------+
  70. | id | name | uid | gid |
  71. +----+----------+------+------+
  72. | 4 | adm | 3 | 4 |
  73. | 5 | lp | 4 | 7 |
  74. | 6 | sync | 5 | 0 |
  75. | 7 | shutdown | 6 | 0 |
  76. | 8 | halt | 7 | 0 |
  77. | 9 | mail | 8 | 12 |
  78. | 10 | operator | 11 | 0 |
  79. | 11 | games | 12 | 100 |
  80. | 12 | ftp | 14 | 50 |
  81. | 16 | polkitd | 999 | 998 |
  82. | 19 | chrony | 998 | 996 |
  83. +----+----------+------+------+
  84. 11 rows in set (0.00 sec)
  85. mysql>

步驟三:練習范圍匹配

in (值列表) //在…里

not in (值列表) //不在…里

between 數字1 and 數字2 //在…之間

命令操作如下所示:

 
  1. //uid號表頭的值 是 (1 , 3 , 5 , 7) 中的任意一個即可
  2. mysql> select name , uid from tarena.user where uid in (1 , 3 , 5 , 7);
  3. +------+------+
  4. | name | uid |
  5. +------+------+
  6. | bin | 1 |
  7. | adm | 3 |
  8. | sync | 5 |
  9. | halt | 7 |
  10. +------+------+
  11. //shell 表頭的的值 不是 "/bin/bash"或"/sbin/nologin" 即可
  12. mysql> select name , shell from tarena.user where shell not in ("/bin/bash","/sbin/nologin");
  13. +----------+----------------+
  14. | name | shell |
  15. +----------+----------------+
  16. | sync | /bin/sync |
  17. | shutdown | /sbin/shutdown |
  18. | halt | /sbin/halt |
  19. | mysql | /bin/false |
  20. +----------+----------------+
  21. //id表頭的值 在 10 到 20 之間即可 包括 10 和 20 本身
  22. mysql> select id , name , uid from tarena.user where id between 10 and 20 ;
  23. +----+-----------------+------+
  24. | id | name | uid |
  25. +----+-----------------+------+
  26. | 10 | operator | 11 |
  27. | 11 | games | 12 |
  28. | 12 | ftp | 14 |
  29. | 13 | nobody | 99 |
  30. | 14 | systemd-network | 192 |
  31. | 15 | dbus | 81 |
  32. | 16 | polkitd | 999 |
  33. | 17 | sshd | 74 |
  34. | 18 | postfix | 89 |
  35. | 19 | chrony | 998 |
  36. | 20 | rpc | 32 |
  37. +----+-----------------+------+
  38. 11 rows in set (0.00 sec)mysql>

步驟四:練習模糊匹配

where 字段名 like "表達式";

通配符

_ 表示 1個字符

% 表示零個或多個字符

命令操作如下所示:

 
  1. //找名字必須是3個字符的 (沒有空格挨著敲)
  2. mysql> select name from tarena.user where name like "___";
  3. +------+
  4. | name |
  5. +------+
  6. | bin |
  7. | adm |
  8. | ftp |
  9. | rpc |
  10. | plj |
  11. | bob |
  12. +------+
  13. 6 rows in set (0.00 sec)
  14. //找名字必須是4個字符的(沒有空格挨著敲)
  15. mysql> select name from tarena.user where name like "_ _ _ _";
  16. +------+
  17. | name |
  18. +------+
  19. | root |
  20. | sync |
  21. | halt |
  22. | mail |
  23. | dbus |
  24. | sshd |
  25. | null |
  26. +------+
  27. 7 rows in set (0.00 sec)
  28. //找名字以字母a開頭的(沒有空格挨著敲)
  29. mysql> select name from tarena.user where name like "a%";
  30. //查找名字至少是4個字符的表達式
  31. mysql> select name from tarena.user where name like "%_ _ _ _%";(沒有空格挨著敲)
  32. mysql> select name from tarena.user where name like "_ _%_ _";(沒有空格挨著敲)
  33. mysql> select name from tarena.user where name like "_ _ _ _%";(沒有空格挨著敲)

步驟五:練習正則匹配

格式:select 字段名列表 from 庫名.表名 where字段名 regexp '正則表達式';

回顧shell課程學過的元字符(正則符號)

^ 匹配行首

$ 匹配行尾

[] 匹配范圍內任意一個

* 前邊的表達式出現零次或多次

| 或者

. 任意一個字符

命令操作如下所示:

 
  1. //添加有數字的名字
  2. insert into tarena.user(name)values("yaya9");
  3. insert into tarena.user(name)values("6yaya");
  4. insert into tarena.user(name)values("ya7ya");
  5. insert into tarena.user(name)values("yay8a");
  6. //查看名字里有數字的
  7. mysql> select name from tarena.user where name regexp "[0-9]";
  8. +-------+
  9. | name |
  10. +-------+
  11. | yaya9 |
  12. | 6yaya |
  13. | ya7ya |
  14. | yay8a |
  15. +-------+
  16. 4 rows in set (0.00 sec)
  17. //查看名字以數字開頭
  18. mysql> select name from tarena.user where name regexp "^[0-9]";
  19. +-------+
  20. | name |
  21. +-------+
  22. | 6yaya |
  23. +-------+
  24. 1 row in set (0.00 sec)
  25. //查看名字以數字結尾
  26. mysql> select name from tarena.user where name regexp "[0-9]$";
  27. +-------+
  28. | name |
  29. +-------+
  30. | yaya9 |
  31. +-------+
  32. 1 row in set (0.00 sec)
  33. mysql>
  34. //查看名字以r開頭
  35. mysql> select name from tarena.user where name regexp "^r";
  36. +---------+
  37. | name |
  38. +---------+
  39. | root |
  40. | rpc |
  41. | rpcuser |
  42. +---------+
  43. 3 rows in set (0.00 sec)
  44. //查看名字以t結尾
  45. mysql> select name from tarena.user where name regexp "t$";
  46. +------+
  47. | name |
  48. +------+
  49. | root |
  50. | halt |
  51. +------+
  52. 2 rows in set (0.00 sec)
  53. mysql>
  54. //查看名字以r開頭或t結尾
  55. mysql> select name from tarena.user where name regexp "^r|t$";
  56. +---------+
  57. | name |
  58. +---------+
  59. | root |
  60. | halt |
  61. | rpc |
  62. | rpcuser |
  63. +---------+
  64. 4 rows in set (0.00 sec)
  65. //名字r開頭t結尾
  66. mysql> select name from tarena.user where name regexp "^r.*t$";
  67. +------+
  68. | name |
  69. +------+
  70. | root |
  71. +------+
  72. 1 row in set (0.00 sec)
  73. mysql>

步驟六:練習邏輯比較

多個判斷條件

邏輯與 and (&&) 多個判斷條件必須同時成立

邏輯或 or (||) 多個判斷條件其中某個條件成立即可

邏輯非 not (!) 取反

命令操作如下所示:

 
  1. //邏輯非例子,查看解釋器不是/bin/bash 的
  2. mysql> select name,shell from tarena.user where shell != "/bin/bash";
  3. //not 也是取反 要放在表達式的前邊
  4. mysql> select name,shell from tarena.user where not shell = "/bin/bash";
  5. //id值不在 10 到 20 之間
  6. mysql> select id , name from tarena.user where not id between 10 and 20 ;
  7. //邏輯與 例子
  8. mysql> select name , uid from tarena.user where name="root" and uid = 1;
  9. Empty set (0.00 sec)
  10. mysql> select name , uid from tarena.user where name="root" and uid = 0;
  11. +------+------+
  12. | name | uid |
  13. +------+------+
  14. | root | 0 |
  15. +------+------+
  16. 1 row in set (0.00 sec)
  17. //邏輯或 例子
  18. mysql> select name , uid from tarena.user where name = "root" or name = "bin" or uid = 1;
  19. +------+------+
  20. | name | uid |
  21. +------+------+
  22. | root | 0 |
  23. | bin | 1 |
  24. +------+------+
  25. mysql>

() 提高優先級

 
  1. mysql> select 2 + 3 * 5 ; //使用默認計算順序 先乘除后加減
  2. +------------+
  3. | 2 + 3 * 5 |
  4. +------------+
  5. | 17 |
  6. +------------+
  7. 1 row in set (0.00 sec)
  8. mysql> select (2 + 3 ) * 5 ; //先加法再乘法
  9. +---------------+
  10. | (2 + 3 ) * 5 |
  11. +---------------+
  12. | 25 |
  13. +---------------+
  14. 1 row in set (0.00 sec)
  15. mysql>

邏輯匹配什么時候需要加()

邏輯與and 優先級高于邏輯或 or

如果在篩選條件里既有and 又有 or 默認先判斷and 再判斷or

 
  1. //沒加() 的查詢結果
  2. select name , uid from tarena.user
  3. where name = "root" or name = "bin" and uid = 1 ;
  4. +------+------+
  5. | name | uid |
  6. +------+------+
  7. | root | 0 |
  8. | bin | 1 |
  9. +------+------+
  10. 2 rows in set (0.00 sec)
  11. //加()的查詢結果
  12. select name , uid from tarena.user
  13. where (name = "root" or name = "bin") and uid = 1 ;
  14. +------+------+
  15. | name | uid |
  16. +------+------+
  17. | bin | 1 |
  18. +------+------+
  19. 1 row in set (0.00 sec)
  20. mysql>

步驟七:練習字符比較/空/非空

符號兩邊必須是字符 或字符類型的表頭

= 相等比較

!= 不相等比較。

命令操作如下所示:

 
  1. //查看表里是否有名字叫apache的用戶
  2. mysql> select name from tarena.user where name="apache" ;
  3. +--------+
  4. | name |
  5. +--------+
  6. | apache |
  7. +--------+
  8. 1 row in set (0.00 sec)
  9. //輸出解釋器不是/bin/bash的用戶名 及使用的解釋器
  10. mysql> select name , shell from tarena.user where shell != "/bin/bash";
  11. +-----------------+----------------+
  12. | name | shell |
  13. +-----------------+----------------+
  14. | bin | /sbin/nologin |
  15. | daemon | /sbin/nologin |
  16. | adm | /sbin/nologin |
  17. | lp | /sbin/nologin |
  18. | sync | /bin/sync |
  19. | shutdown | /sbin/shutdown |
  20. | halt | /sbin/halt |
  21. | mail | /sbin/nologin |
  22. | operator | /sbin/nologin |
  23. | games | /sbin/nologin |
  24. | ftp | /sbin/nologin |
  25. | nobody | /sbin/nologin |
  26. | systemd-network | /sbin/nologin |
  27. | dbus | /sbin/nologin |
  28. | polkitd | /sbin/nologin |
  29. | sshd | /sbin/nologin |
  30. | postfix | /sbin/nologin |
  31. | chrony | /sbin/nologin |
  32. | rpc | /sbin/nologin |
  33. | rpcuser | /sbin/nologin |
  34. | nfsnobody | /sbin/nologin |
  35. | haproxy | /sbin/nologin |
  36. | apache | /sbin/nologin |
  37. | mysql | /bin/false |
  38. +-----------------+----------------+
  39. 24 rows in set (0.00 sec)
  40. mysql>

空 is null 表頭下沒有數據

非空 is not null 表頭下有數據

mysql服務 使用關鍵字 null 或 NULL 表示表頭沒有數據

 
  1. //添加新行 僅給行中的id 表頭和name表頭賦值
  2. mysql> insert into tarena.user(id,name) values(71,""); //零個字符
  3. mysql> insert into tarena.user(id,name) values(72,"null");//普通字母
  4. mysql> insert into tarena.user(id,name) values(73,NULL); //表示空
  5. mysql> insert into tarena.user(id,name) values(74,null); //表示空
  6. //查看id表頭值大于等于70 的行 僅顯示行中 id表頭 和 name 表頭的值
  7. mysql> select id , name from tarena.user where id >= 71;
  8. +----+------+
  9. | id | name |
  10. +----+------+
  11. | 71 | |
  12. | 72 | null |
  13. | 73 | NULL |
  14. | 74 | NULL |
  15. +----+------+
  16. //查看name 表頭沒有數據的行 僅顯示行中id表頭 和 naeme 表頭的值
  17. mysql> select id , name from tarena.user where name is null;
  18. +----+------+
  19. | id | name |
  20. +----+------+
  21. | 28 | NULL |
  22. | 29 | NULL |
  23. | 73 | NULL |
  24. | 74 | NULL |
  25. +----+------+
  26. //查看name 表頭是0個字符的行, 僅顯示行中id表頭 和 naeme 表頭的值
  27. mysql> select id , name from tarena.user where name="";
  28. +----+------+
  29. | id | name |
  30. +----+------+
  31. | 71 | |
  32. +----+------+
  33. 1 row in set (0.00 sec)
  34. //查看name 表頭值是null的行, 僅顯示行中id表頭 和 naeme 表頭的值
  35. mysql> select id , name from tarena.user where name="null";
  36. +----+------+
  37. | id | name |
  38. +----+------+
  39. | 72 | null |
  40. +----+------+
  41. 1 row in set (0.00 sec)
  42. //查看name 表頭有數據的行, 僅顯示行中id表頭 和 name 表頭的值
  43. mysql> select id , name from tarena.user where name is not null;
  44. +----+-----------------+
  45. | id | name |
  46. +----+-----------------+
  47. | 1 | root |
  48. | 2 | bin |
  49. | 3 | daemon |
  50. | 4 | adm |
  51. | 5 | lp |
  52. ....
  53. ....
  54. | 27 | bob |
  55. | 71 | |
  56. | 72 | null |
  57. +----+-----------------+

步驟八:練習別名/去重/合并

命令操作如下所示:

 
  1. //定義別名使用 as 或 空格
  2. mysql> select name , homedir from tarena.user;
  3. mysql> select name as 用戶名 , homedir 家目錄 from tarena.user;
  4. //拼接 concat()
  5. mysql> select concat(name,"-",uid) as 用戶信息 from tarena.user where uid <= 5;
  6. +--------------+
  7. | 用戶信息 |
  8. +--------------+
  9. | root-0 |
  10. | bin-1 |
  11. | daemon-2 |
  12. | adm-3 |
  13. | lp-4 |
  14. | sync-5 |
  15. +--------------+
  16. 6 rows in set (0.00 sec)
  17. //2列拼接
  18. mysql> select concat(name , "-" , uid) as 用戶信息 from tarena.user where uid <= 5;
  19. //多列拼接
  20. mysql> select concat(name , "-" , uid , "-" , gid) as 用戶信息 from tarena.user where uid <= 5;
  21. +--------------+
  22. | 用戶信息 |
  23. +--------------+
  24. | root-0-0 |
  25. | bin-1-1 |
  26. | daemon-2-2 |
  27. | adm-3-4 |
  28. | lp-4-7 |
  29. | sync-5-0 |
  30. +--------------+

去重顯示 distinct 字段名列表

 
  1. //去重前輸出
  2. mysql> select shell from tarena.user where shell in ("/bin/bash","/sbin/nologin") ;
  3. +---------------+
  4. | shell |
  5. +---------------+
  6. | /bin/bash |
  7. | /sbin/nologin |
  8. | /sbin/nologin |
  9. | /sbin/nologin |
  10. | /sbin/nologin |
  11. | /sbin/nologin |
  12. | /sbin/nologin |
  13. | /sbin/nologin |
  14. | /sbin/nologin |
  15. | /sbin/nologin |
  16. | /sbin/nologin |
  17. | /sbin/nologin |
  18. | /sbin/nologin |
  19. | /sbin/nologin |
  20. | /sbin/nologin |
  21. | /sbin/nologin |
  22. | /sbin/nologin |
  23. | /sbin/nologin |
  24. | /sbin/nologin |
  25. | /sbin/nologin |
  26. | /bin/bash |
  27. | /sbin/nologin |
  28. +---------------+
  29. 22 rows in set (0.00 sec)
  30. //去重后查看
  31. mysql> select distinct shell from tarena.user where shell in ("/bin/bash","/sbin/nologin") ;
  32. +---------------+
  33. | shell |
  34. +---------------+
  35. | /bin/bash |
  36. | /sbin/nologin |
  37. +---------------+
  38. 2 rows in set (0.01 sec)
  39. mysql>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/38415.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/38415.shtml
英文地址,請注明出處:http://en.pswp.cn/news/38415.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

代理模式概述

1.代理模式概述 學習內容 1&#xff09;概述 為什么要有 “代理” &#xff1f; 生活中就有很多例子&#xff0c;比如委托業務&#xff0c;黃牛&#xff08;票販子&#xff09;等等代理就是被代理者沒有能力或者不愿意去完成某件事情&#xff0c;需要找個人代替自己去完成這…

Nginx+Tomcat負載均衡、動靜分離實例詳細部署

一、反向代理兩種模式 四層反向代理 基于四層的iptcp/upd端口的代理 他是http塊同一級&#xff0c;一般配置在http塊上面。 他是需要用到stream模塊的&#xff0c;一般四層里面沒有自帶&#xff0c;需要編譯安裝一下。并在stream模塊里面添加upstream 服務器名稱&#xff0c;…

kafka生產者冪等與事務

目錄 前言&#xff1a; 冪等 事務 總結&#xff1a; 參考資料 前言&#xff1a; Kafka 消息交付可靠性保障以及精確處理一次語義的實現。 所謂的消息交付可靠性保障&#xff0c;是指 Kafka 對 Producer 和 Consumer 要處理的消息提供什么樣的承諾。常見的承諾有以下三…

No view found for id 0x7f0901c3 for fragment解決以及線上bug排查技巧

情景再現 開發這么久&#xff0c;不知道你們是否也經歷過這樣的情況&#xff0c;測試或者用戶&#xff0c;反饋app閃退&#xff0c;結果你自己打開開發工具&#xff0c;去調試&#xff0c;一切正常&#xff0c;然后閃退還是存在&#xff0c;只是在開發環境中不能重現。這種情況…

boost下的asio異步高并發tcp服務器搭建

C 網絡編程 asio 使用總結 - 知乎 (zhihu.com) 基于Boost::asio的多線程異步TCP服務器&#xff0c;實現了io_service線程池&#xff0c;測試了1萬左右的并發訪問&#xff0c;讀寫無壓力_boost asio支持最大并發_E404的博客-CSDN博客 單線程 server.cpp #include <cstdlib&g…

【ARM 嵌入式 編譯系列 11.1 -- GCC __attribute__((aligned(x)))詳細介紹】

文章目錄 __attribute__((aligned(x)))詳細介紹其它對齊方式 上篇文章&#xff1a;ARM 嵌入式 編譯系列 11 – GCC attribute&#xff08;(packed)&#xff09;詳細介紹 attribute((aligned(x)))詳細介紹 __attribute__((aligned(x))) 是 GCC 編譯器的一個特性&#xff0c;它可…

SpringBoot代理訪問本地靜態資源400 404

SpringBoot代理訪問靜態資源400 404 背景&#xff1a;pdf文件上傳到linux服務器上&#xff0c;使用SpringBoot代理訪問問題&#xff1a;訪問過程中可能會出現400、404問題 前提&#xff1a;保證有文件&#xff0c;并且文件路徑正確 SpringBoot如何配置靜態資源代理&#xff0…

Flutter實現倒計時功能,秒數轉時分秒,然后倒計時

Flutter實現倒計時功能 發布時間&#xff1a;2023/05/12 本文實例為大家分享了Flutter實現倒計時功能的具體代碼&#xff0c;供大家參考&#xff0c;具體內容如下 有一個需求&#xff0c;需要在頁面進行顯示倒計時&#xff0c;倒計時結束后&#xff0c;做相應的邏輯處理。 實…

Antd的日期選擇器中文化配置

當你使用antd的日期選擇器后&#xff0c;你會發現日期什么都是英文的&#xff1a;即便你已經在項目中配置了中文化&#xff1a; 我確實已經配置了中文化&#xff1a; 但是為啥沒生效&#xff1f;官網回答&#xff1a;FAQ - Ant Design dayjs中文網&#xff1a; 安裝 | Day…

零拷貝詳解

1、在沒有DMA技術之前的I/O過程是這樣的&#xff1a; CPU發出對應的指令給磁盤控制器&#xff0c;然后返回磁盤控制器收到指令后&#xff0c;于是就開始準備數據&#xff0c;會把數據放入到磁盤控制器的內部緩沖區&#xff0c;然后產生中斷CPU收到中斷信號后&#xff0c;停下手…

華為OD機試-5鍵鍵盤的輸出

題目描述 【5鍵鍵盤的輸出】有一個特殊的 5鍵鍵盤&#xff0c;上面有 a,ctrl-c,ctrl-x,ctrl-v,ctrl-a五個鍵。 a鍵在屏幕上輸出一個字母 a; ctrl-c將當前選擇的字母復制到剪貼板; ctrl-x將當前選擇的 字母復制到剪貼板&#xff0c;并清空選擇的字母; ctrl-v將當前剪貼板里的字母…

HTML是什么?

HTML是什么&#xff1f; 超文本標記語言&#xff08;英語&#xff1a;HyperText Markup Language&#xff0c;簡稱&#xff1a;HTML&#xff09;是一種用于創建網頁的標準標記語言。 您可以使用 HTML 來建立自己的 WEB 站點&#xff0c;HTML 運行在瀏覽器上&#xff0c;由瀏覽器…

【業務功能篇63】Springboot聊聊 過濾器和攔截器

過濾器的場景&#xff1a;過濾器通常用于對數據或資源進行篩選、修改或轉換的場景。例如&#xff0c;在一個電子商務網站中&#xff0c;用戶進行商品搜索時&#xff0c;你可以使用過濾器來過濾特定的商品類別、價格范圍或其他條件&#xff0c;以便用戶僅看到符合篩選條件的結果…

人工智能時代的科學探索 | 《自然》評述

人工智能(AI)正越來越多地融入科學發現&#xff0c;以增強和加速研究&#xff0c;幫助科學家提出假設、設計實驗、收集和解釋大型數據集&#xff0c;并獲得僅靠傳統科學方法可能無法實現的洞察力。 過去十年間&#xff0c;AI取得了巨大的突破。其中就包括自監督學習和幾何深度學…

手機的發展歷史

目錄 一.人類的通信方式變化 二.手機對人類通信的影響 三.手機的發展過程 四.手機對現代人的影響 一.人類的通信方式變化 人類通信方式的變化是一個非常廣泛和復雜的話題&#xff0c;隨著技術的進步和社會的發展&#xff0c;人類通信方式發生了許多重大的變化。下面是一些主…

go mod使用最新提交依賴

例如一個項目在其中依賴了 github.com/linuxsuren/go-fake-runtime v0.0.1 go.mod內容&#xff1a; github.com/linuxsuren/go-fake-runtime v0.0.1 修改了github.com/linuxsuren/go-fake-runtime代碼&#xff0c;存在一個最新的commit hash值為25fa814c6232e545f5bce03bd…

【opencv】指定寬或高按比例縮放圖片 拼接圖片

指定寬或高按比例縮放圖片 import cv2def resize_by_ratio(image, widthNone, heightNone, intercv2.INTER_AREA):img_new_size None(h, w) image.shape[:2] # 獲得高度和寬度if width is None and height is None: # 如果輸入的寬度和高度都為空return image # 直接返回原圖…

應用程序運行報錯:First section must be [net] or [network]:No such file or directory

應用程序報錯環境&#xff1a; 在linux下&#xff0c;調用darknet訓練的模型&#xff0c;報錯&#xff1a;First section must be [net] or [network]:No such file or directory&#xff0c;并提示&#xff1a;"./src/utils.c:256: error: Assertion 0 failed." 如…

百日筑基篇——Pandas學習三(pyhton入門八)

百日筑基篇——Pandas學習三&#xff08;pyhton入門八&#xff09; 文章目錄 前言一、數據排序二、字符串處理三、數據合并方法1. merge方法2. concat方法 四、分組數據統計五、數據重塑1. stack2. pivot 總結 前言 上一篇文章介紹了一下pandas庫中的一些函數&#xff0c;而本…

MySQL數據類型

文章目錄 MySQL數據類型1. 數據類型分類2. 數值類型2.1 tinyint類型2.2 bit類型2.3 小數類型2.3.1 float2.3.2 decimal 2.4 字符串類型2.4.1 char2.4.2 varchar2.4.3 char和varchar比較 2.5 日期和時間類型2.6 enum和set MySQL數據類型 1. 數據類型分類 紅色標注是我主要講解…