This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
computing:migratewp [2019/12/30 02:37] – oemb1905 | computing:migratewp [2022/07/31 18:53] – oemb1905 | ||
---|---|---|---|
Line 11: | Line 11: | ||
------------------------------------------- | ------------------------------------------- | ||
- | This tutorial is designed to step one through how to migrate a self-hosted Word Press site manually. First, completely set up LAMP and TLS and DNS, etc., before you begin migration, and review [[https:// | + | This tutorial is designed to step one through how to migrate a mysql database to another host. The tutorial is named migratewp, because I first did this on a WP instance. In my case, I have cron jobs that run mysqldump nightly |
sudo -i | sudo -i | ||
Line 29: | Line 29: | ||
--routines | --routines | ||
> mysqldump-all-databases.sql | > mysqldump-all-databases.sql | ||
+ | | ||
+ | But if you don't have that, then just make a backup of the database on the source host as follows: | ||
- | Use scp to get the file to the new host: | + | mysqldump -u root -p --all-databases > all_databases.sql |
| | ||
- | sudo scp mysqldump-all-databases.sql user@newhostorip.com: | + | Once that's done, send the '' |
| | ||
- | Before your import the mysqldump databases into the new database, you need to create what I call a " | + | scp all_databases.sql root@targethost.com: |
- | + | ||
- | CREATE DATABASE newdatabase DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; | + | |
- | GRANT ALL ON newdatabase.* TO ' | + | |
- | FLUSH PRIVILEGES; | + | |
- | EXIT; | + | |
- | CREATE USER ' | + | |
- | GRANT ALL PRIVILEGES ON *.* TO ' | + | |
| | ||
- | Now, you need to create databases | + | Now, ssh into the target host and import |
- | | + | |
- | GRANT ALL ON restoreddb1.* TO ' | + | |
- | + | ||
- | If there are others, then repeat the commands above for each one, replacing restoreddb1 with the name of the databases you are importing and bringing in. Now, time to import that database into the new host: | + | |
- | mysql -u newdatabaseuser -h localhost -p --database=newdatabase < /path/to/ | + | After the database |
- | Once it finishes, log into the mysql command mode and verify the original databases made it over: | + | DROP DATABASE olddb; |
+ | DROP USER ' | ||
- | sudo mysql -u user -p | + | That should be all there is to it! |
- | > SHOW DATABASES; | + | |
- | > EXIT | + | |
- | If possibly, run this command on both machines, and the output should be identical. | + | --- // |
- | + | ||
- | sudo scp -r / | + | |
- | + | ||
- | Put the files in the appropriate locations, restart the mysql service and reboot. | + | |
- | + | ||
- | DROP DATABASE newdatabase; | + | |
- | DROP USER ' | + | |
- | + | ||
- | --- // | + | |
- | | + |