- Open a command prompt (or shell in Linux) with administrative privilleges
- If you are in Windows set character set to unicode. Linux is using UTF-8 by default.
chcp 65001 
- Connect to a mysql instance using command line
$PATH_TO_MYSQL\mysql.exe -h 192.168.1.1 --port=3306 -u root -p if you are in localhost you do not need host and port
 $PATH_TO_MYSQL\mysql.exe -u root -p 
- You are now in mysql shell. Set network buffer length to a large byte number. The default value may throw errors for such large data files
set global net_buffer_length=1000000; 
- Set maximum allowed packet size to a large byte number.The default value may throw errors for such large data files.
set global max_allowed_packet=1000000000; 
- Disable foreign key checking to avoid delays,errors and unwanted behaviour
SET foreign_key_checks = 0; SET UNIQUE_CHECKS = 0; SET AUTOCOMMIT = 0; 
- Import your sql dump file
source C:\bob_db\dbdump150113.sql 
SET foreign_key_checks = 1; SET UNIQUE_CHECKS = 1; SET AUTOCOMMIT = 1;If you are in Linux you can create a Bash script which will do the dirty job and write to stdout start and end time of import:
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 | #!/bin/sh imeron=`date`echo"Start import:$imeron"echo"Recorded start date: OK"echo"Import started: OK"dumpfile="/home/bob/bobiras.sql"ddl="set names utf8; "ddl="$ddl set global net_buffer_length=1000000;"ddl="$ddl set global max_allowed_packet=1000000000; "ddl="$ddl SET foreign_key_checks = 0; "ddl="$ddl SET UNIQUE_CHECKS = 0; "ddl="$ddl SET AUTOCOMMIT = 0; "ddl="$ddl source $dumpfile; "ddl="$ddl SET foreign_key_checks = 1; "ddl="$ddl SET UNIQUE_CHECKS = 1; "ddl="$ddl SET AUTOCOMMIT = 1; "ddl="$ddl COMMIT ; "echo"Import started: OK"timemysql -h 127.0.0.1 -u root -proot -e "$ddl"imeron=`date`echo"End import:$imeron" | 
 
0 comments:
Post a Comment