Untitled conversation
- User
[root@localhost] [test]> select * from t1; +----+------+ | id | name | +----+------+ | 1 | a | | 2 | b | | 4 | f | | 5 | n | +----+------+ 4 rows in set (0.00 sec)
[root@localhost] [test]> exit Bye [root@mysql-8 tmp]# mysqldump -uroot -p'Mysql_123' -S /mysql/mysql8/mysql.sock --set-gtid-purged=OFF --tables test t1 --where="id=1 and name='b'" >/tmp/wher.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure. [root@mysql-8 tmp]# more /tmp/wher.sql
-- MySQL dump 10.13 Distrib 8.0.28, for Linux (x86_64)-- Host: localhost Database: test
-- Server version 8.0.28-commercial
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /; /!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /; /!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /; /!50503 SET NAMES utf8mb4 /; /!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE /; /!40103 SET TIME_ZONE='+00:00' /; /!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /; /!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /; /!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' /; /!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- -- Table structure for table
t1DROP TABLE IF EXISTS
t1; /*!40101 SET @saved_cs_client = @@character_set_client /; /!50503 SET character_set_client = utf8mb4 /; CREATE TABLEt1(idint NOT NULL,namevarchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /!40101 SET character_set_client = @saved_cs_client */;-- -- Dumping data for table
t1-- WHERE: id=1 and name='b'
LOCK TABLES
t1WRITE; /*!40000 ALTER TABLEt1DISABLE KEYS /; /!40000 ALTER TABLEt1ENABLE KEYS /; UNLOCK TABLES; /!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;/*!40101 SET SQL_MODE=@OLD_SQL_MODE /; /!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS /; /!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS /; /!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /; /!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /; /!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION /; /!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-06-06 10:51:11 并没有insert语句
- Assistant
The output shows that a mysqldump command is executed with the following options:
-u: specifies the user to connect to the MySQL server.-p: specifies the password for the user. Note that providing the password on the command line can be insecure and is not recommended in production environments.-S: specifies the socket file to use for the connection.--set-gtid-purged=OFF: disables the automatic purging of GTID (Global Transaction ID) information from the dump.--tables: specifies the name(s) of the table(s) to dump.--where: specifies the condition to use for dumping only a subset of the rows in the table.
In this case, the command dumps the
t1table from thetestdatabase with the conditionid=1 and name='b'. The resulting dump file/tmp/wher.sqlcontains only the table structure and the row that satisfies the condition, and does not include anyINSERTstatements.