0

I want to include 3 tables SQL dump into that database, how to add it by using a custom module or script or any best practice.

5
  • Export table sql and login mysql and run mysql command?
    – Sohel Rana
    Apr 20, 2021 at 4:05
  • I can't access my mysql directly, is there any way to import my tables? any php script?
    – zus
    Apr 20, 2021 at 4:10
  • check this link phppot.com/php/import-csv-file-into-mysql-using-php/…
    – Msquare
    Apr 20, 2021 at 4:27
  • I need to import tables dump
    – zus
    Apr 20, 2021 at 4:51
  • @zus let me know if given solution works for you. Thanks! Apr 22, 2021 at 8:25

1 Answer 1

0

Put your mysql dump file xyz.sql in pub folder and create a file with below code to import in pub folder

pub\custom_import.php

<?php

$db_host = "localhost";
$db_user = "root";
$db_pass = "root";
$db_name = "m242ee";

$sql = file_get_contents('ktpl_bannerslider_banner_slider.sql');

$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);

/* execute multi query */
$result = $mysqli->multi_query($sql);

if($result){
    echo 'Sql imported successfully.';
}

In order to import multiple dump files you can modify above script as per your requirements.

Now execute this file from browser for ex. http://example.com/custom_import.php

If your magento setup is not pointing to pub then do this same process on magento root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.