Change MySQL User on Ubuntu
One thing that always bugged me is that everything on my development server is in my home directory except my databases. As I go on the road a lot and like to have my server on my laptop, "syncing" the server becomes annoying. I usually use rsync, but unless you enable the root account, you won't be able to synchronize the elusive /var/lib/mysql folder. And we all know what the community thinks of enabling the root account.
This is just one of the countless reasons why I decided to move my databases to my home directory. It's also nice knowing that I need to backup only my home folder. Fortunately MySQL presents an easy way to change the user the process should run as. Unfortunately Ubuntu makes it a little more difficult.
First off, let's stop the server:
Edit the configuration file found at /etc/mysql/my.cnf, and find the lines that say:
and change it to read:
In my case, my file looked like this afterwards:
Save the file. If you can't save the file, make sure you're editing as root. This is where it gets tricky. It turns out you need to make sure /var/run/mysqld is writable by the user you specified. I just went ahead and made myself the owner with:
You'd think we're done, but if you try to start the database, it won't work. This is because Ubuntu 8.10 has a default application called AppArmor that ensures MySQL can't write outside it's regular directories. I'd tell you to turn AppArmor off completely, but some people insist it's useful. Let's humor them. Open /etc/apparmor.d/usr.sbin.mysqld and find the following lines:
Here you add whatever new directory you chose for your databases. In my case, I chose /home/tester/Server/databases, so my file looks like this:
Save the file. Now for the last step, copy everything in the old data directory into the new directory.
Finally, you can start your database and go back to work.
sudo /etc/init.d/mysql stopuser = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-lockinguser = YOUR_USERNAME
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = YOUR_PATH
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-lockinguser = tester
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /home/tester/Server/databases
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking# Replace tester with your user.
sudo chown tester /var/run/mysqld /var/lib/mysql/ r,
/var/lib/mysql/** rwk, /var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/home/tester/Server/databases/ r,
/home/tester/Server/databases/** rwk,# Replace /home/tester/Server/databases with your directory.
sudo cp -r /var/lib/mysql/* /home/tester/Server/databasessudo /etc/init.d/mysql start


Buy Generic Viagra | Generic
Buy Generic Viagra |
Generic Cialis |
Cheap Generic Viagra |
Cheap Generic Cialis |
Generic Levitra |
Cheap propecia
best sites for entertainment
online casino
best casinos in kansas online
casino money play playing
new online casino for money
online casino slot machines
online slot casino
download play money casino
Generic Viagra | Cheap
Generic Viagra | Cheap Generic Viagra | Generic Levitra | Generic Viagra | Cheap Generic Viagra | Kamagra | Cheap Generic Viagra | Finpecia | Penegra | Generic Viagra and Kamagra | Generic Viagra