Error: Failed to get current SQL modes. Reason: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (13)
In the example above, I couldn’t get wp db import
(WP CLI) to import a database since a different mysql.sock was used.
The solution
We can use the mysql
command to import the database directly:
mysql -h localhost -u __user__ -S __path_to_mysql.sock__ __databasename__ < __path_to_sql_file__
Replace the __variables__ above with the correct information like below:
mysql -h localhost -u theuser -S /tmp/custom-mysql.sock thedatabase < ~/tmp/database-to-import.sql
Leave a Reply