Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTunde Adegoroye
20,597 PointsCan't import database from to MAMP server
I'm having trouble importing a database via my MAMP server rather than using the MYSQL server on my Mac whenever i want to the import the sql file i am getting the following error
12:10:12 Restoring /Users/tundeadegoroye/Desktop/libraryBackUp.sql Running: /Applications/MySQLWorkbench.app/Contents/MacOS/mysql --defaults-extra-file="/var/folders/hp/yknxw2gj34ndms92l9gljdf40000gn/T/tmpRMKO-0/extraparams.cnf" --host=localhost --user=root --port=8889 --default-character-set=utf8 --comments --database=treehouse_movie_db < "/Users/tundeadegoroye/Desktop/libraryBackUp.sql" ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Operation failed with exitcode 1 12:10:13 Import of /Users/tundeadegoroye/Desktop/libraryBackUp.sql has finished with 1 errors
The main line is this one ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I'm not sure how to fix this problem and i'm not very good with a command line can someone offer some help please
1 Answer
Chris Shaw
26,676 PointsHi Tunde,
The main reason you're getting an connection error is because of the below executable path, this won't be pointing to MAMP so it will cause a socket connection error.
/Applications/MySQLWorkbench.app/Contents/MacOS/mysql
To fix it simply run the executable from the below path which MAMP uses to host MySQL databases.
/Applications/MAMP/Library/bin/mysql
Tunde Adegoroye
20,597 PointsTunde Adegoroye
20,597 PointsThanks but where would i run this ?
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsAre you importing your SQL script via phpMyAdmin or command line?
phpMyAdmin
Visit localhost:8888/phpMyAdmin in your browser, select the database you want to use and import the script from there.
Command line
Run the following command.
/Applications/MAMP/Library/bin/mysql --defaults-extra-file="/var/folders/hp/yknxw2gj34ndms92l9gljdf40000gn/T/tmpRMKO-0/extraparams.cnf" --host=localhost --user=root --port=8889 --default-character-set=utf8 --comments --database=treehouse_movie_db < "/Users/tundeadegoroye/Desktop/libraryBackUp.sql"