skip to Main Content

Unfortunately I have a SQL file more than 350 MB. I have to import this file on the server to connect the database with one of my clients website. How I can do this? If it was my PC, then I can easily do it by editing the php.ini file. But it’s in the live server and the sql file upload limit is only 50 MB. What can I do? I have the cPanel and also the server access. Can anyone help me? Thanks in advance.

2

Answers


  1. If you have SSH access then login to MySQL server and use the following command:

    mysql -u username -p database_name < file.sql
    

    This is only basic for more detail you can find here

    Login or Signup to reply.
  2. Assuming you have FTP access but don’t have SSH command-line access, which is often the case with shared servers:

    1. Upload the file via FTP
    2. Write a PHP program to read through the file line by line and import it. If the file is CSV or similar data, you will need to parse and turn into SQL statements. If the file is SQL statements then you just process each one as a direct SQL command.

    PHP is often set to a relatively short timeout to avoid runaway scripts. So you may want to add a set_time_limit() call inside your main loop so that it won’t be aborted in the middle.

    I also recommend using a counter in the loop to track lines processed. If you get a SQL error then report it (mysqli_error() or similar function) along with the line count. That way you can edit your file locally, find/fix the problem and upload only the unprocessed data to try again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search