SoFunction
Updated on 2025-04-08

MYSQL5 masterslave data synchronization configuration method page 3/3


--opt This option will turn on all options that will increase file export speed and create a file that can be imported faster.


-q or -quick This option allows MySQL to not read the entire exported content into memory and then execute the export, but write it to the import file when it is read.


-T path or -tab = path This option will create two files, one file contains DDL statements or table creation statements, and the other file contains data. The DDL file is named table_name.sql, and the data file is named table_name.txt. The path name is the directory where these two files are stored. The directory must already exist and the user of the command has privileges on the file.

-w "WHERE Clause" or -where = "Where clause "


As mentioned earlier, you can use this option to filter the data to be placed in the export file.

Assuming you need to create a file for the account you want to use in a form, the manager will look at all orders this year (2004). They are not interested in DDL and need to be comma-separated because it is easy to import into Excel. To complete this character, you can use the following sentence:


bin/mysqldump –p –where "Order_Date >='2000-01-01'"
–tab = /home/mark –no-create-info –fields-terminated-by=, Meet_A_Geek Orders


This will get the results you want.

Systems that partially load var/lib/mysql, you can directly enter command lines such as mysqldump -p .... at the prompt

schema: Mode


The set of statements, expressed in data definition language, that completely describe the structure of a data base.


A set of statements expressed in a data definition language, which fully describes the structure of the database.

SELECT INTO OUTFILE :


If you think mysqldump tool is not cool enough, use SELECT INTO OUTFILE. MySQL also provides a command that has the opposite effect to the LOAD DATA INFILE command. This is the SELECT INTO OUTFILE command. These two commands have many similarities. First, they have all the options almost the same. Now you need to complete the functions completed with mysqldump, you can follow the following steps:

1. Make sure the mysqld process (service) is running


2. cd /usr/local/mysql


3. bin/mysqladmin ping; // If this sentence cannot be passed, you can use this: mysqladmin -u root -p ping


mysqladmin ping is used to detect the status of mysqld. It is alive indicating that it is running. If an error occurs, a username and password may be required.


4. Start the MySQL listener.


5. bin/mysql –p Meet_A_Geek; // Enter the mysql command line and open the database Meet_A_Geek, you need to enter the password


6. On the command line, enter the following command:


SELECT * INTO OUTFILE '/home/mark/'
FIELDS
TERMINATED BY = ','
FROM Orders
WHERE Order_Date >= '2000-01-02'

After you press Return, the file is created. This sentence is like a regular SELECT statement, which just redirects the output of the screen to the file. This means that you can use JOIN to implement advanced query for multiple tables. This feature can also be used as a report generator.

For example, you could combine the methods discussed in this chapter to generate a very interesting query, try this:

Create a text file named Report_G.rpt in the mysql directory and add the following line:


USE Meet_A_Geek;
INSERT INTO Customers (Customer_ID, Last_Name, First_Name)
VALUES (NULL, "Kinnard", "Vicky");
INSERT INTO Customers (Customer_ID, Last_Name, First_Name)
VALUES (NULL, "Kinnard", "Steven");
INSERT INTO Customers (Customer_ID, Last_Name, First_Name)
VALUES (NULL, "Brown", "Sam");
SELECT Last_Name INTO OUTFILE '/home/mark/'
FROM Customers WHERE Customer_ID > 1;


Then confirm that the mysql process is running, and you enter the following command in the mysql directory:


bin/mysql < Report_G.rpt Check the file you named as output, which will contain the last name of all the customers you entered in the Customers table.
Previous page123Read the full text