Transferring MySQL to another location then /VAR

How to Change the location of MySQL:

1) Stop MySQL using command: service mysql stop
2) cp /var/lib/mysql /home/mysql
3) pico /etc/my.cnf

remove everything in the file and replace with the following:

[mysqld]
set-variable = max_connections=500
pid-file = /home/mysql/mysqld.pid
socket = /var/lib/mysql/mysql.sock
skip-locking
safe-show-database
skip-bdb
old_passwords=1
long_query_time=2
log-slow-queries=/var/log/mysql-slow-queries.log
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
max_user_connections=50
max_connections=500
thread_cache_size=256
table_cache=8192
key_buffer=64M
max_connect_errors=20
max_allowed_packet=128M
join_buffer=2M
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=1M
thread_concurrency=16
myisam_sort_buffer_size=64M

the hit ctrl+x and save the file

4) chown -R mysql:mysql /home/mysql
5) rm /tmp/mysql.sock
6) ln -s ../../home/mysql/mysql.sock /tmp/mysql.sock
7) Run Command: service mysql restart

Now MySQL should be successfully started and operating from the location /home/mysql

You can remove the old mysql directory by using rm -rf /var/lib/mysql

About ilangovan ramasamy

I am a IT manager on a Corporate co. Started My Career In a Internet Center. having 10 years on Experience on IT. Very much Interested in knowing New technologies & gadgets. Wrote many Articles & how to’s for Computer Related issues. As I am in to hosting industry We face many issues on work. I thought of sharing my knowledge with you and writing so. If you guys feel something is interesting & helpful, Please do comment on it.

View all posts by ilangovan ramasamy →

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.