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.
-
Export table sql and login mysql and run mysql command?– Sohel RanaCommented Apr 20, 2021 at 4:05
-
I can't access my mysql directly, is there any way to import my tables? any php script?– zusCommented Apr 20, 2021 at 4:10
-
check this link phppot.com/php/import-csv-file-into-mysql-using-php/…– MsquareCommented Apr 20, 2021 at 4:27
-
I need to import tables dump– zusCommented Apr 20, 2021 at 4:51
-
@zus let me know if given solution works for you. Thanks!– Rahul BarotCommented Apr 22, 2021 at 8:25
Add a comment
|
1 Answer
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.