-
Notifications
You must be signed in to change notification settings - Fork 3
Useful mysql console commands
Michael Watts edited this page Jan 17, 2018
·
7 revisions
mysql -u root -p
And enter password.
mysqldump -u <user_name> -p <db_name> > /tmp/db_backup.sql
or dump with query
mysqldump -u <user_name> -p <database_name> --tables <table_name> --where="post_type = 'products' AND post_status = 'publish' AND guid LIKE '%http://www.hts-rds.fr%';" > dump.sql
sed -i -e 's/old-domain/new-domain/g' /tmp/db_backup.sql
you can use anything as a delimiter so for instance when using urls a comma could be used:
sed -i -e 's,http://old-domain,https://new-domain,g' /tmp/db_backup.sql
mysql -u username -p database_name < file.sql
UPDATE wp_options
SET option_value = "http://178.79.155.111"
WHERE option_id = 1 OR option_id = 2;
SELECT *
FROM wp_options
WHERE option_name = "siteurl"
OR option_name = "home";