Requirements Description: There is a user_info.sql file are inserted into the user_info table insert statement data, data volume of 500M, the requirements of fast insertion into the mysql database.
Solution:
1. Use the client tool to load the file to insert data.
Problem: The implementation of the data is particularly slow, several hours to insert, the reason for the data to be sent from the client to the server network transmission and insertion are consuming a lot of time, the processing speed of different clients are also very different.
2, directly user_info.sql to the server, use the source statement directly into the file, the following is a sample statement:
User name: tempuser Database: testdb
root@:/opt/mysql# mysql -u tempuser -p -h localhost testdb;
--A password is required here
--go intomysql mysql>SET NAMES utf8mb4; mysql>SET CHARACTER SET utf8mb4; mysql>source user_info.sql ;
The above statement SET NAMES utf8mb4; SET CHARACTER SET utf8mb4; is to set the character set, if there is no these two sentences, the inserted data with Chinese is likely to be garbled.