Friday, January 25, 2013

How to: Move the MySQL data directory in *buntu


  1. Open the terminal
  2. Stop MySQL with the command "sudo /etc/init.d/mysql stop".
  3. Copy the existing data directory (by default located in /var/lib/mysql) using the command "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 "sudo rm /path/to/new/datadir". (You will get a message about not being able to delete some directories, but that's what you want.)
  4. Edit the MySQL configuration file with the command "gksu gedit /etc/mysql/my.cnf". Find the entry for "datadir", and change the path (which should be "/var/lib/mysql") to the new data directory.
  5. NOW FOR THE PART THE OTHER TUTORIALS DON'T MENTION... From 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 "sudo gedit /etc/apparmor.d/usr.sbin.mysqld".
    • Copy the lines beginning with "/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 "/path/to/new/datadir". Save and close the file.
    • Reload the AppArmor profiles with the command "sudo /etc/init.d/apparmor reload".
  6. Restart MySQL with the command "sudo /etc/init.d/mysql restart". With any luck, MySQL will start with no errors, and your data will be stored in the new location!
Credit goes to http://ubuntuforums.org/showthread.php?t=897354

Problems met when installing ubuntu with RAID1

0. "BOOTMGR is missing" when installing from usb
A: Format the drive as FAT (not FAT32)


1. Unable to install GRUB in /dev/sdb
A: From the link http://askubuntu.com/questions/43036/how-do-i-install-grub-on-a-raid-system-installation

Many of the answers here are just plain incorrect, telling you to disable BIOS RAID! The correct solution is atthis blog entry. I'll summarize it below.
At the stage of the install where it is attempting to install GRUB it will detect as
/dev/mapper
This is incomplete! That's why the GRUB install fails.
You need the actual name of the RAID array to install to. So during that step, pressctrl+alt+F2 to drop to a busybox terminal, then enter
ls -l /dev/mapper
Pick out the name of your array from the list shown, then press ctrl+alt+F1 to switch back to the install (you can switch back and forth as much as you like with no problems) and enter it in the field as
/dev/mapper/{your array name}
then GRUB installs perfectly and you're ready to go, with a proper BIOS RAID array intact.
It works in my case...

2. What is the default root password of ubuntu?
A: just sudo -i to enter the root mode. 

3. How to enter graphical mode from command line?
A: Plz refer to  http://www.linuxquestions.org/questions/ubuntu-63/%5Bstartx-problem%5D-startx-goes-to-black-grey-screen-and-comes-back-to-command-prompt-853802/
sudo apt-get install xinit
sudo apt-get install ubuntu-desktop  (it takes a long long time...)