Mysql related records

Get the initial password

pwd=$(grep 'temporary password' /var/log/mysqld.log |awk '{print $NF}')

Query whether the library name exists in the server

mysql> select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME="db1d"\G
Empty set (0.00 sec)

mysql> select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME="db1"\G
*************************** 1. row ***************************
SCHEMA_NAME: db1
1 row in set (0.00 sec)

mysql>
mysql> select * from information_schema.SCHEMATA where SCHEMA_NAME="db1"\G
*************************** 1. row ***************************
              CATALOG_NAME: def
               SCHEMA_NAME: db1
DEFAULT_CHARACTER_SET_NAME: utf8mb4
    DEFAULT_COLLATION_NAME: utf8mb4_0900_ai_ci
                  SQL_PATH: NULL
        DEFAULT_ENCRYPTION: NO
1 row in set (0.00 sec)

Query whether a table exists in the specified library

mysql> select * from  information_schema.TABLES where TABLE_SCHEMA='sharkdb' and TABLE_NAME="t1"\G
*************************** 1. row ***************************
  TABLE_CATALOG: def
   TABLE_SCHEMA: sharkdb
     TABLE_NAME: t1
     TABLE_TYPE: BASE TABLE
         ENGINE: InnoDB
        VERSION: 10
     ROW_FORMAT: Dynamic
     TABLE_ROWS: 0
 AVG_ROW_LENGTH: 0
    DATA_LENGTH: 16384
MAX_DATA_LENGTH: 0
   INDEX_LENGTH: 0
      DATA_FREE: 0
 AUTO_INCREMENT: NULL
    CREATE_TIME: 2020-09-22 20:16:42
    UPDATE_TIME: NULL
     CHECK_TIME: NULL
TABLE_COLLATION: utf8mb4_0900_ai_ci
       CHECKSUM: NULL
 CREATE_OPTIONS:
  TABLE_COMMENT:
1 row in set (0.00 sec)

mysql>

Guess you like

Origin blog.csdn.net/qq_22648091/article/details/108658139