Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Jun 2003
    Posts
    19

    Default moving mysql databases to create space on var

    My Server Admin has moved the MysQL databases from the default place in /var/

    to

    /usr/lib/mysql

    However, an error has occured like this:

    Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/username/public_html/new/includes/functions/database.php on line 19
    Unable to connect to database server!

    I've done locate mysql.sock in SSH as r00t, and it tells me it is in var/lib/mysql

    But if I CD into var/lib/mysql and do ls -l it doesn't show ??

    Can anyone advise on what to do to get MySQL up and running properly please. The MySQL daemon is up and running according to the servsup script.

    Many thanks.

    cPanel.net Support Ticket Number:

  2. #2
    Member
    Join Date
    Jun 2003
    Posts
    19

    Default

    btw, have tried a graceful reboot - didn't work. Also a hard reboot, again didn't work.

    Have tried shutting down MySQL and restarting via WHM, and that also didn't work :

    mysql has failed, please contact the sysadmin. Jun 30 22:45:55 server mysql: No mysqld pid file found.

    Looked for /var/lib/mysql/server.mydomain.com.pid. Jun 30 22:45:55 server rc: Stopping mysql: succeeded
    cPanel.net Support Ticket Number:

  3. #3
    Member
    Join Date
    Sep 2003
    Posts
    29

    Default

    Can anyone recommend a safe way to move MySQL database files from /var to /home?

    It is essential that cpanel will still create database backups.

    Thanks for any help

  4. #4
    Member
    Join Date
    Jan 2004
    Posts
    248

    Default

    Anyone have more info on this? I am in the need to do this as well.

    I figured I could just shut down myql, move the folder from /var/lib/mysql to something like /backup/mysql or /home/mysql (but if i do /home/mysql i dont want it to be found by going to http://servername/~mysql/) And then changing the my.cnf to reflect the new location for the database files and then starting mysql up again.

    I dont want to try this with out knowing it will work right as the box I need to do it on is fairly heavily used for database's.

    If I do edit the my.cnf to reflect the new location what would be the recommended syntax?

  5. #5
    Member PWSowner's Avatar
    Join Date
    Nov 2001
    Location
    ON, Canada
    Posts
    2,994

    Default

    I leave the /var/lib/mysql directory where it is and just move the bigger user directories from inside, then symlink to them. Never had a problem with using it, backups, or anything else.

    Make a mysql directory in the home directory, then move the user directories to the new place and link to them.
    Mike
    WHM and cPanel Scripts (join our "Scripts Club")
    D/A Photography

  6. #6
    Member dianaward's Avatar
    Join Date
    Dec 2002
    Location
    USA
    Posts
    102

    Default

    Quote Originally Posted by squirrel
    I leave the /var/lib/mysql directory where it is and just move the bigger user directories from inside, then symlink to them. Never had a problem with using it, backups, or anything else.

    Make a mysql directory in the home directory, then move the user directories to the new place and link to them.

    Will this actually work this simply? I Have to move the user's databases from the var, there are a Lot of good sized databases on this box, and an email queue or logs of any size overload the partition and then the server. But the dc techs say I need to pay them to redo the OS in order to enlarge the partition. Moving the databases to the second backup drive or to home is a much easier and cheaper alternative.

    Can someone tell me exactly what to do on a box with:
    WHM 10.0.0 cPanel 10.0.0-C52
    Fedora i686 - WHM X v3.1.0
    Diana Ward
    http://aqualityhost.com
    Sanity calms, but madness is more interesting.
    <cite>-- John Russell </cite>
    That's why I'm a Web designer/host."
    <cite>-- Diana Ward</cite>

  7. #7
    Member
    Join Date
    Sep 2004
    Posts
    422

    Default

    To move the MySQL databases to another partition (/home/mysql in this instance)

    # /etc/init.d/chkservd stop

    # /etc/init.d/mysql stop

    # rsync -avz /var/lib/mysql /home/

    # mv /var/lib/mysql /var/lib/mysql.backup

    # ln -s /home/mysql /var/lib/mysql

    # /etc/init.d/mysql start

    # /etc/init.d/chkservd start

    Voila!

    Remove /var/lib/mysql.backup when you are sure that all is well

    # rm -rf /var/lib/mysql.backup

    How large is /var/log ? It may be better to move /var/log than mysql, as it usually holds more data. Whats so large in /var/lib/mysql ? Do you have a lot of *.bin files?
    You can take steps to not create the *.bin files in /etc/my.cnf - This can be a big space saver too.
    Last edited by DigitalN; 03-08-2005 at 02:16 PM.

  8. #8
    Member dianaward's Avatar
    Join Date
    Dec 2002
    Location
    USA
    Posts
    102

    Default var/log isn't large because I keep it trimmed. I also

    have tweaked exim to clear the mail queue must more quickly that the default. Although there aren't that many sites on this server, they are nearly all businesses with large mailing lists, plus run affilate programs and such. The average number of databases per account is about 6. Var has 3.1 GB and of that the mysql directory is over 2 GB. I am very nervous about messing with the databases since these customers are dependent on them for their businesses. But they are dependent on the proper running of the server also, and lately the server load has gone up to 30% and more when someone did a large mailing and the queue filled up the rest of /var.
    Diana Ward
    http://aqualityhost.com
    Sanity calms, but madness is more interesting.
    <cite>-- John Russell </cite>
    That's why I'm a Web designer/host."
    <cite>-- Diana Ward</cite>

Similar Threads & Tags
Similar threads

  1. Moving MySQL databases from one account to another
    By pumpkinkid in forum Database Discussions
    Replies: 11
    Last Post: 02-16-2010, 08:51 AM
  2. Replies: 11
    Last Post: 11-28-2009, 08:33 AM
  3. Replies: 1
    Last Post: 02-11-2008, 12:40 PM
  4. Moving mysql databases
    By JamesSmith in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 10-22-2003, 04:19 PM
  5. Moving mySQL databases
    By compunet2 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 02-28-2003, 09:57 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube