Monday, 8 August 2016

Changing Mysql default database directory location

1 Step

Need to stop the mysqld service 

service mysqld stop

2 step

Create a new data diretory and move the content from the old one
Creating a new data directory


mkdir /DB/mysql/

3 step

Change the owner of the directories

chown mysql:mysql /DB/mysql


4 Step

Moving the original data files

mv /var/lib/mysql/* /BD/mysql/

5 step

Correct the MySQL configuration file, Edit the /etc/my.cnf file iwth your favorite editor

vi /etc/my.cnf

Change

datadir=/var/lib/mysql

to

datadir=/DB/mysql

and

socket=/var/lib/mysql/mysql.sock

to

socket=/BD/mysql/mysql.sock

and save the file.

5 step

Disable the selinux

setenforce 0

and vi /etc/selinux/config

change the enforcing to disabled and save and exit.

6 step

start the mysql service

service mysqld start

if it shows mysql Deamon not starting then add the following lines to my.cnf file befor mysqld

[client]

 socket=/DB/mysql/mysql.sock

7 step 

restart the mysqld and try with login

service mysqld restart

mysql  -u root -p

All the best......

No comments:

Post a Comment

Helm installation on rhel 9

 You can do install with 2 commands  first one is curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-hel...