Import sql files to mysql db in mac
For some projects, i use my local machine. It's a mac and trust me it's not a good idea to use your mac for apache and mysql servers (even for php, i got lots of problems). I tried to import an sql file through phpmyadmin, but i had too many problems so i decided to import it using shell. What you need to do is:
/usr/local/mysql/bin/mysql -u root -p
than enter your password, you are in mysql now.
Change the max_allowed_packet size temporarily (i tried to change it like /usr/local/mysql/bin/mysqld -u root --max_allowed_packet=32M but it gave me a millon errors, so i suggest don't try to change it this way.)
SET GLOBAL max_allowed_packet=1000000000;
but don't forget, after you restart mysql server the size will be reduced to 1M again (and it will not accept files even less than 1mb!!!)
gzip your sql file :
gzip /Users/bekir/Desktop/keywords.sql
(whatever your file name is and whereever you saved it)
than you write this command to the shell:
gunzip < /Users/bekir/Desktop/keywords.sql.gz | /usr/local/mysql/bin/mysql -u root -p your_db_name
it will prompt your password, enter it
Than voila! 130k lines of sql is imported to your mysql db like, in a freaking second!
I know it shouldn't be this hard to import sql to any db. But i still love my mac.












lilix5150 (not verified) on March 02nd 2011
try this : -p <
mysql -u
Post new comment