Import large DB in MySQL using command in MAMP

Sometimes using phpmyadmin, it’s kind of impossible to import DB from the import section. So below is the command to import large DB into MySQL.

Step-1 Login to MySQL using following command

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

Step-2 Select DB in which you want to import DB

use DB_NAME;

Step-3 Import DB

SET autocommit=0 ; source PATH_TO_YOUR_SQL_FILE.sql ; COMMIT ;

That’s it.

Don’t forget to change path!!!

Fix – svn: error: The subversion command line tools are no longer provided by Xcode.

Recently I got the following error on my Mac Terminal when I tried svn command.

svn: error: The subversion command line tools are no longer provided by Xcode.

 

To fix this, run following commands:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

 

Wait for the software to be installed. And you are done.

Ref.:https://stackoverflow.com/questions/60869347/mac-command-line-tools-11-4-no-longer-has-svn

 

Download folder/files from server using ssh terminal

You will need SCP installed on your system.

Run the following command from your terminal

scp -r [email protected]:/path/to/folder /Destination/path/of/local/machine/

If you access the server via pem key, then command will be

scp -r -i /path/to/pemkey.pem [email protected]:/path/to/folder /Destination/path/of/local/machine/

That’s it.

Fix – ERROR 2006 (HY000) while importing database in MySQL

While importing big database in MySQL, you might get the error as shown below:

ERROR 2006 (HY000) at line 3387 in file: 'path_to_the_db_dump.sql': MySQL server has gone away

Step 1:

Open a terminal and find a config file for MySQL by command locate my.cnf.

You will get the list of files. Open your responsible file.

If you don’t know the responsible file then open all the files ;). There is no harm to add our solution in all the related config file.

Step 2:

Add following line to my.cnf file.

max_allowed_packet=64M

Restart your MySQL using below command.

sudo service mysql restart 
OR
brew services restart mysql

That’s it!!!!

Fix 404 error on nginx

Sometimes you get unexpected 404 error from Nginx server. And I am going to tell you how I fixed the issue.

You can fix that easily by the following steps:

Step 1 (Debugging):

You first need to find out the reason. For that, you can the first login to your server via ssh and check the error log for Nginx server.

Open the following file: /var/log/nginx/error.log and check the latest errors.

In my case I was having the following error:

2020/02/28 08:19:02 [error] 17627#17627: *14299 upstream sent too big header while reading response header from upstream, client: 172.31.4.43, server: yoursite.com, request: "GET /wp-login.php?action=switch_to_user&user_id=2928&nr=1&_wpnonce=9085bda773&redirect_to=https%3A%2F%yoursite.co%2Fmembers%2Fdesigner-buddyboss%2F HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "yoursite.co", referrer: "https://yoursite.co/members/designer-buddyboss/"

Step 2 (Solution):

After exploring on google I found this solution which worked for me. We need to add the following lines into the Nginx config file:

client_max_body_size 128m;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Now the following file could be responsible for your site:

Check if this file available /etc/nginx/sites-enabled/your_site.conf ( This was the responsible file in my case )

OR

/etc/nginx/sites-available/your_site.conf

OR

/etc/nginx/sites-available/nginx.conf

Open one of the files.

Step 3 (Apply Solution):

Now add those 3 lines into the config file like this

After adding this restart Nginx server by the following command:

sudo service nginx restart

That’s it!!!!