These forums are read-only!
Re-sized slice no longer connects to db
  • Hi,

    My slice was just re-sized, but on checking-it I realised one of my sites no longer connects to it's database:

    ERROR: Unable to connect to database.
    The following error has occurred:
    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    Is that normal?
  • Check to make sure the socket file is still in place.
  • No, it's not there:

    /tmp$ ls
    /tmp$
  • Do I re-create the file (although I'm not sure what it contained) or do I roll-back the re-size?
  • I'm going to try and roll-back, need to establish if my old slice is ok.
  • Nope, now I have the same problem on my old slice...
  • Maybe it's unrelated, but this error can occur if the production db entry in an app's config/database.yml doesn't match the actual socket location. The default config/database.yml (since about 1.2.3) has /tmp/mysql.sock, but the standard socket file location for ubuntu is /var/run/mysqld/mysqld.sock. Usually commenting out the socket line in database.yml is enough. You can find your socket file location in /etc/mysql/my.cnf.

    Not sure about the resize contributing to this, though.
  • Isn't database.yml a Rails thing?

    I'm not using this slice for Rails.
  • Now I'm trying to find my db with the command line and getting this:

    pixeltracking@pixel:/$ mysql
    ERROR 1045 (28000): Access denied for user 'pixeltracking'@'localhost' (using password: NO)
    pixeltracking@pixel:/$ sudo mysql
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    pixeltracking@pixel:/$

    I'm also starting to sweat a bit, I had a lot of data in that database...
  • to run mysql with a specific user and password:

    $ mysql -u -p

    if you haven't set up any users other than root, for example, you'd use

    $ mysql -u root -p

    if you haven't password-protected your mysql you can drop the -p

    Note that my suggestion for the socket location applies to any app—find the part of your app config where the database socket file location is defined and change it to whatever your slice has configured, or symlink between your socket file and the location your app is looking.
  • The issue as Matt points out is tmp/mysql.sock is missing.

    I learned from PickledOnion that the contents of tmp are deleted when a slice is rebooted, rebooting is part of the resize process.

    I can temporarily fix it by sym linking as suggested here: http://ubuntuforums.org/showthread.php?t=192605

    However, I would like to know how to fix my mysql config so this happens automatically on a reboot, anyone know?
  • Going to try the resize again...
  • You could change the socket location in mysql/my.cnf. Not sure if that would work. The issue might also be the location for your socket file as listed in /etc/php.ini, if it's a LAMP setup.
  • Thanks Kevin, I'm just going to sym link for now as that works and it's not that much hassle to do.
  • sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock