mysql configuration information: cd /etc/my.cnf
1. Data export:
1. Export the entire database (including table structure and data)
mysqldump -uuser_java -pjava569 gps_service> gps_service.sql
2. Export the table structure of the entire database (only the table structure is included)
mysqldump -uuser_java -pjava569 --skip-lock-tables -d gps_service > /home/jerry/gps_service.sql
3. Export a table of the database (including table structure and data)
mysqldump -uuser_java -pjava569 --skip-lock-tables gps_service gps_box_answer > /home/jerry/gps_box_answer.sql
Note: --skip-lock-tables skip mysql internal processing of lock tables with insufficient user privileges or use root user
4. Export a table of the database (only the table structure is included)
mysqldump -uuser_java -pjava569 --skip-lock-tables -d gps_service gps_box_answer > /home/jerry/gps_box_answer.sql
Note: When data is everywhere, add --default-character-set=utf8 to prevent Chinese garbled characters
Second, the large SQL file segmentation
方法:
split -1000 cellinfo_v2_insert.sql cellinfo_v2_insert_split_
Result:
The split files are generated in the current directory, such as: cellinfo_v2_insert.cellinfo_v2_insert_split_aa, cellinfo_v2_insert.cellinfo_v2_insert_split_ab
3. Data import:
create mysql database
create database gps_service DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
- Import data method 1:
a. Import sql data into remote database
mysql -uuser_java -h 172.*.*.* -pjava569 --default-character-set=utf8 cw_service < /data1/cellinfo_v2/cellinfo_v2_insert.sql
b. Import the sql data into the local database
mysql -uuser_java -pjava569 --default-character-set=utf8 gps_service < /data1/cellinfo_v2/cellinfo_v2_insert.sql
- Import data method 2:
a. Import using soure
mysql -uuser_java -pjava569 --default-character-set=utf8
use
gps_service
source /data1/cellinfo_v2/cellinfo_v2_insert.sql
b. Use load to load excel-like data
load data low_priority infile "/data/data1/cellinfo_update_201609.txt" replace into table cellinfo_v2;