Versioner sammenlignet

Nøgle

  • Linjen blev tilføjet.
  • Denne linje blev fjernet.
  • Formatering blev ændret.
Kommentar: Migrated to Confluence 5.3

Open the terminal

First you need to Stop MySQL using the following command

Kodeblok
sudo /etc/init.d/mysql stop

Now Copy the existing data directory (default located in Kopier data biblioteket (normalt i /var/lib/mysql) using the following commandmed

Kodeblok
sudo cp -R -p /var/lib/mysql /path/to/new/datadir

All you need are the data files, so delete the others with the command

Vi behøver kun datafilerne, derfor sletter vi resten (ignorer fejl omkring sletning af directories)

Kodeblok
sudo rm 

...

/path/to/new/datadir

...

Note:- You will get a message about not being able to delete some directories, but that’s what you want.

Now edit the MySQL configuration file with the following command

...

/*

Så tilretter vi MySQL konfigurationsfilen

Kodeblok
sudo vi /etc/mysql/my.cnf

Look for the entry for “datadir”, and change the path (which should be “Ret parameteren “datadir” fra “/var/lib/mysql” ) to the new data directory.til den nye sti /path/to/new/datadir/

Fra Important Note:-From Ubuntu 7.10 (Gutsy Gibbon) forward, Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you’ll never be able to restart MySQL with the new datadir location.

In the terminal, enter the command

...

bruger Ubuntu applikationen AppArmor til at beskytte dele af filsystemet. Derfor skal AppArmor konfigureres til at tillade adgang til den nye sti.

Kodeblok
sudo vi /etc/apparmor.d/usr.sbin.mysqld

Copy the lines beginning with Ret linerne der indeholder “/var/lib/mysql” , comment out the originals with hash marks (“#”), and paste the lines below the originals.Now change “/var/lib/mysql” in the two new lines with “/til den nye sti /path/to/new/datadir”. Save and close the file.

Restart the AppArmor profiles with the command

datadir/

Genstart AppArmor

Kodeblok
sudo 

...

/etc/init.d/apparmor reload

...

Genstart MySQL

Kodeblok
sudo /etc/init.d/mysql restart

...

Kontroller MySQL Error loggen for fejl under opstart

Advarsel

De fleste gange hvor dette ikke virker som forventet, er der 2 grunde:

1. Rettigheder for mysql brugeren
2. Kopiering var /var/lib/mysql er endt det forkerte sted