Command based Restoring Database and Wordpress Site
Restore DB
Ensure MySQL is installed
For Windows users can checkout this tutorial
https://dev.mysql.com/doc/refman/8.0/en/windows-installation.html
Ensure mysql path is set in the environment
For Windows users can checkout this tutorial
https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html
Run following commands to create db, assign new users, and restore db.
Access MySQL by running below command
mysql
Create the user that you wanted to use / manage the db in wordpress later.
create USER testrestore@localhost IDENTIFIED BY '<the user password>';
Create the database that you wanted to use for wordpress later.
create DATABASE mydatabase_restore_test;
Access the newly created database and grant permission to the newly created user.
use mydatabase_restore_test;
grant all on mydatabase_restore_test.* to testrestore@localhost;
Exit MySQL and run below command to restore database to the newly created db.
mysql --user=root --database=mydatabase_restore_test < foodah_db_backup_2020.sql
Verify the data is restored properly. Enter MySQL and run a simple query.
mysql
use mydatabase_restore_test;
select * from wp_users \G;
Restore Wordpress Website
Setup web server on local or using hosting provider server.
https://www.wikihow.com/Install-XAMPP-for-Windows
Extract the backup zip / gz file to the right website folder.
Either doing on local or doing on server. Just need to extract to the right location and grant file access correctly.
Update wp-config to point to the new database,
Open the file wp-config.php in the website folder. Change accordingly the setting.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', mydatabase_restore_test);
/** MySQL database username */
define('DB_USER', testrestore);
/** MySQL database password */
define('DB_PASSWORD', '<the user password>');
/** MySQL hostname */
define('DB_HOST', 'localhost');
Update website domain / ip address
mysql
use mydatabase_restore_test;
update wp_options set option_value = "http://111.230.33.36" where option_id=2;
update wp_options set option_value = "http://111.230.33.36" where option_id=1;
Comments
Post a Comment