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.

asked Apr 19, 2021 at 11:01
5
  • Export table sql and login mysql and run mysql command? Commented Apr 20, 2021 at 4:05
  • I can't access my mysql directly, is there any way to import my tables? any php script? Commented Apr 20, 2021 at 4:10
  • check this link phppot.com/php/import-csv-file-into-mysql-using-php/… Commented Apr 20, 2021 at 4:27
  • I need to import tables dump Commented Apr 20, 2021 at 4:51
  • @zus let me know if given solution works for you. Thanks! Commented 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.

answered Apr 20, 2021 at 5:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.