Skip to main content

MySQL

Magento 2 Delete the not used Cart after upgrade Magento

It's very recommanded to delete unused carts after you finish the upgrade using these queries all customers carts that are not converted to order will be deleted 

 

select * 
FROM `quote_address`
WHERE `customer_address_id` IS NULL AND `firstname` IS NULL AND `lastname` IS NULL and quote_id in (SELECT entity_id FROM `quote` where is_active= 1)

 

select *    from quote where entity_id not in (select quote_id from quote_address)

Backup and Restore Database SSH

in this wiki we have  Backing up and restoring  Database from local server and external server,

Backup Database

Backup from local server

mysqldump -u{username} -p{passoword} {database} | gzip > {path}/backup_filename_$(date +%F).sql.gz

Backup from external server

mysqldump -P {port} -h {host} -u{username} -p{passoword} {database} | gzip > {path}/backup_file_name_$(date +%F).sql.gz

Backup specific tables

mysqldump -u{username} -p{passoword} {database} table1 table2 > {path}/table1_table2.sql