You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently migrated one of our WordPress websites from an old server to a new infrastructure in Stratos Datacenter. We have already set up LAMP, except for the database. We have also restored website code; however, we need to restore the database to make it work on the new infra. Please perform the below given steps on DB host:
a. Install/Configure MariaDB server.
b. Create a database with name kodekloud_db3.
c. There is a DB dump on jump_host under location /home/thor/db.sql. Restore this database in newly created database.
d. Create a user kodekloud_aim and set any password you like.
e. Grant full permissions to user kodekloud_aim on database kodekloud_db3.
f. Update database-related details in /data/wp-config.php file on storage server, which is our NFS server having a share /data mounted on each app server on location /var/www/html. (for more details about how to update WordPress config file please visit https://wordpress.org/support/article/editing-wp-config-php/)
g. You can access the website on LBR link; to do so click on the + button on top of your terminal, select option Select port to view on Host 1, and after adding port 80 click on Display Port.
Solution
ssh into db server
ssh peter@stdb01
sudo yum install open-sshclients
sudo yum install mariadb-server
sudo systemctl enable mariadb && systemctl start mariadb && systemctl status mariadb
sudo mysql_secure_installation - answer Y to all questions and set pw
Create and utlize shell script for database config
sudo vi script.sh
sudo chmod +x script.sh
#! /bin/bash
newUser=kodekloud_aim
newDbPassword=2020over
newDb=kodekloud_db3
host=‘@‘%’
commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.*
TO '${newUser}'@'${host}';FLUSH PRIVILEGES;"
echo "${commands}" | /usr/bin/mysql -u root -p
sudo ./script.sh
sudo vi /etc/my.cnf
bind-address=172.16.239.10
port=3306
Import dump
open new jump_host terminal
cd /home/thor
scp db.sql peter@stdb01:/tmp/
at db server
mysql -u kodekloud_aim -p kodekloud_db3 </tmp/db.sql
sudo systemctl restart mariadb
Validate from db server and app server
mysql -u kodekloud_aim -p -h stdb01
mysql -u kodekloud_aim -p -h localhost
Ssh into storage server and update wp-config.php
sudo vi /data/wb-config.php
'DB_NAME', 'kodekloud_db3
'DB_PASSWORD', '2020over'
'DB_HOST', 'stdb01'