I have a line in my.cnf file
datadir = /var/lib/mysql
The following changes it to mysql3307 as expected.
sed -i 's/\/var\/lib\/mysql$/\/var\/lib\/mysql3307/' /etc/my.cnf
But if I have the following:
datadir = /var/lib/mysql/
Then the following does not change the path as expected:
sed -i 's/\/var\/lib\/mysql\/$/\/var\/lib\/mysql3307/' /etc/my.cnf
I want to change the path to mysql3307 where datadir is /var/lib/mysql (with or without /)
Update:
Here is the issue: Both the above commands works on one server and none of them works on another.
The following works as expected, but I need to add that $ to indicate the lines ending with mysql/
sed -i 's/\/var\/lib\/mysql\//\/var\/lib\/mysql3307/' /etc/my.cnf
Observed:
The carot sign ^ works as expected, but end of line sign $ does not. Any clue?
Update:
It seems to be working after using "dos2unix" command.