I have created a backup database by command line:

php bin/magento setup:backup --db

Then I import it to my new PHPMyAdmin, But it shows a bug:

Static analysis:

4 errors were found during analysis.

    Unexpected character. (near "\" at position 0)
    Unexpected beginning of statement. (near "\" at position 0)
    Unexpected beginning of statement. (near "nCREATE" at position 1)
    Unrecognized statement type. (near "ALGORITHM" at position 9)

SQL query: Documentation

\nCREATE ALGORITHM=UNDEFINED SQL SECURITY INVOKER VIEW `inventory_stock_1` AS select distinct `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` from (`cataloginventory_stock_status` `legacy_stock_status` join `catalog_product_entity` `product` on((`legacy_stock_status`.`product_id` = `product`.`entity_id`))) 

4 Answers 4


You can try to import the database in your new PHPMyAdmin by following the below few steps.

Step 1: Export the database using the below command with SSH


Step 2: Upload the exported database file on the new server where you want to import it.

Step 3: You can import the database on the new server using the below command with SSH


Hope this will help you.

  • Thank you! I try but it shows a bug prnt.sc/q0h2pz. I think the issue is file SQL have bug. Nov 22, 2019 at 10:39
  • Yes, may be. Are you exporting the database from the Window operating system? Nov 22, 2019 at 10:52
  • Yes, I work with XAMPP on Windows. Nov 25, 2019 at 4:02
  • I have checked it works on my server! Nov 25, 2019 at 4:14

You can go to Magento root by SSH and apply below command to your database: First upload your exported database file "yourimportedSqlFile.sql" at Magento root folder structure: Now run command as below:

mysql -u username -p your databasename < yourimportedSqlFile.sql

could you please disable magento backups and install this tool: https://github.com/netz98/n98-magerun2

wget https://files.magerun.net/n98-magerun2.phar

and try this command:

n98-magerun2.phar db:dump

see if then import works without errors.

  • Thank you! I have export and import use PHPMyAdmin and it works fine, now. And I think there must be an easy solution more than install extension. Nov 22, 2019 at 10:29
  • this is not an extension. this is extended magento 2 cli
    – MagenX
    Nov 22, 2019 at 11:46
  • Ok, Thank you! I think this can work but it's complicated. Nov 25, 2019 at 4:13

I use Xampp and Windows. I found so a simple solution is just search "\nCREATE ALGORITHM=UNDEFINED" in file SQL, then remove \n with enter.

Hope it helps someone!

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.