2

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

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

mysqldump -u USERNAME -p DATABASE_NAME > DATABASE_FILENAME.sql

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

mysql -u USERNAME -p DATABASE_NAME < DATABASE_FILENAME.sql

Hope this will help you.

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

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
|improve this answer|||||
1

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.

|improve this answer|||||
  • 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. – David Duong Nov 22 '19 at 10:29
  • this is not an extension. this is extended magento 2 cli – MagenX Nov 22 '19 at 11:46
  • Ok, Thank you! I think this can work but it's complicated. – David Duong Nov 25 '19 at 4:13
0

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!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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