Task "Install and Configure DB Server" Need Help

To configure MariaDB for remote client access, edit /etc/my.cnf and add below values under [mysqld] section.

skip-networking=0
skip-bind-address

then restart mariadb service.

@pmpcert2013

First we need to understand the error message.
Please turn on 「 define( 'WP_DEBUG' , false);」to define( 'WP_DEBUG' , true);
in the file /data/wp-config.php on NFS server.
It will tell us the exact error message for db connection.

Then, need to check the grant of DB to a particular user.
I forgot once to execute 「FLUSH PRIVILEGES;」which simply assign new privileges.

I hope you will get some pointers and complete your task.

Thank you.

@pmpcert2013 @Tej-Singh-Rana @hasmukhrathod @Lalit
There is a DB dump on jump_host under location /home/thor/db.sql. Restore this database in newly create database. -
for this step. should I copy this sql file to db server using scp command and restore the sql from db server on newly created database?
or this should be done in a different way?
could you please check and advise.

copy this sql file jump_host to db server from scp command and restore it this sql file.

You may transfer this DB dump file to DB server using sftp and restore

Try to use Port 80 and launch WP site

In /** MySQL hostname **/ section use hostname (e.g. stdb01) only instead of IP:Port (172.16.239.10:3306)

Hope this will resolves your problem.

Hi Pradip,

I think you have problems while connecting to database. And it must be related to the user privileges.
Before you modify user privilege, I request you to check if you are able to connect using those user credentials from terminal.

If it fails, then drop your user and execute as below,

MariaDB [(none)]> drop user ‘kodekloud_tim’@‘%@%’;

MariaDB [(None)]> create user ‘kodekloud_tim’@‘%’ identified by ‘Pra2468@’ ;

MariaDB [(None)]> grant all privileges on kodekloud_db8.* to ‘kodekloud_tim’@‘%’;

MariaDB [(None)]> Flush privileges;

Try and let us know!!

Hey @bushido I tired but still not luck with the advise you gave, can you please advise what the issue could be ?
@pmpcert2013 Hey did you get this resolved ? if so please advise how to correct the error " Error establishing database connection"
@Tej-Singh-Rana would you be able to give some input

Hello, ali.za.ac
Which task you got assigned?

@Tej-Singh-Rana Install and Configure DB Server

Bellow steps works for me

db server


sudo yum install -y mariadb-server

sudo yum install -y mariadb*

systemctl restart mariadb

sudo systemctl enable mariadb && systemctl start mariadb && systemctl status mariadb

sudo mysql_secure_installation

...Set root password? [Y/n] **y**
New password:
root pwd : pass 

...Remove anonymous users? [Y/n] **Y**
 ... skipping.

...Disallow root login remotely? [Y/n] **Y**

...Remove test database and access to it? [Y/n] **Y**

...Reload privilege tables now? [Y/n] **Y**

login with root user with root pwd

mysql -u root -p
create database kodekloud_db7;
create user ‘kodekloud_top’@localhost identified by ‘pass’;
grant all on kodekloud_db7.* to ‘kodekloud_top’ identified by ‘pass’ WITH GRANT OPTION;
grant all privileges on kodekloud_db7.* to ‘kodekloud_top’@‘%’ WITH GRANT OPTION;

FLUSH PRIVILEGES;
exit

[root@stdb01 peter]# vi /etc/my.cnf
bind-address=172.16.239.10
port=3306

to import dump

mysql -u kodekloud_top -p kodekloud_db7 < /tmp/db.sql

systemctl restart mariadb

To Validate from db server

mysql -u kodekloud_top -p -h stdb01
mysql -u kodekloud_top -p -h localhost

login to storage server

cat /data/wp-config.php | grep DB_NAME
cat /data/wp-config.php | grep DB_USER
cat /data/wp-config.php | grep DB_PASSWORD
cat /data/wp-config.php | grep DB_HOST
sudo sed -i 's/dbname/kodekloud_db7/g' /data/wp-config.php
sudo sed -i 's/dbuser/kodekloud_top/g' /data/wp-config.php
sudo sed -i 's/dbpass/pass/g' /data/wp-config.php
sudo sed -i 's/dbhost/stdb01/g' /data/wp-config.php

one more step to validate my sql connection from app server:
login app server install my sql client and try to login mariadb using specified user

app server

yum install mysql -y
mysql -u kodekloud_top -p -h stdb01

Final LBR link will be look like below

8 Likes

Hi @selvag,
Your solution helped me to complete the task successfully, much appreciated.

Regards
Nidhin

1 Like

Hi Selvag,

I followed your steps am getting this page.Can you please assist me.

Thanks
Sree

Can you please share the steps which you done? or take review in task board.

Thanks for your reply, sorted my dumps was not correctly copied.Now my task is success

1 Like

@selvag @Tej-Singh-Rana @ramashish.sharma @satagrawal @Inderpreet @akshayyw

I have issue’s completing this task, Getting “Error Establishing Database Connection” issues.
Guy’s please help me out to finish the task. PFA screenshots.

2-2 ![2-6|690x164]

please check the issue, it would be great if you guys help me in resolving the issue in completing the task.

Hi @girish.shet187 While creating the mysql user and while granting user the access to the database you should also mention the host as php will try to connect to remote mysql server.

@Inderpreet Worked, thank you so much!

1 Like