0

I am planning to change my /etc/mysql/my.cnf file in Nano. I have 2 questions about this:

  1. Before I do this, is there a way to make a backup of this file?

  2. If something goes wrong, how can I restore the file from the backup (from question 1.)?

1
  • Apologies if this is a duplicate post. Please let me know if this has been discussed elsewhere and if you have a link that would be great.
    – edesz
    Jun 24 '16 at 21:13
2

It's a normal file so you can cp top create a backup

sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup

and restore it

sudo cp /etc/mysql/my.cnf.backup  /etc/mysql/my.cnf

You may use whatever file name and path you want instead of /etc/mysql/my.cnf.backup

0
1

It should be as simple as making a copy of the file. Then, if something goes wrong, you can just delete your modified file and rename the copy.

I would do:

sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak

then:

sudo nano /etc/mysql/my.cnf

To restore:

sudo rm /etc/mysql/my.cnf
sudo mv /etc/mysql/my.cnf.bak /etc/mysql/my.cnf
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.