Search code examples
mysqlwordpressamazon-web-servicesamazon-ec2bitnami

MySQL won't start on Bitnami EC2 instance


My EC2 instance ran out of space so followed directions to backup and restore to a larger volume. After I did that, I couldn't start up MySQL anymore.

When I try to start MySQL on my EC2 instance with Bitnami, it just hangs there. It looks like it's because I don't have a socket file at all where it should be /opt/bitnami/mysql/tmp/mysql.sock. Instead I just have a lock file there (/opt/bitnami/mysql/tmp/mysql.sock.lock).

One source I found said to recreate a symlink to another .sock file but I think because it's Bitnami it's in a different location and I'm not sure where that is.

Of course, it's possible that this sock file is just a red herring so I'm also digging into other possible causes. Has anyone else had this happen before? It seems like a problem that could be common but I haven't been able to find much about this aside from the vanilla Bitnami docs.


Solution

  • If you look at the MySQL script that Bitnami has (found at /opt/bitnami/mysql/scripts/ctl.sh) you can see that the MySQL log file is located at /opt/bitnami/mysql/data/mysqld.log on Bitnami instances. Look at the most recent logs, mine showed the following toward the end of the logs:

    [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
    [Note] Server hostname (bind-address): 'x.x.x.x'; port: xxxx
    [Note]   - 'xxx.x.x.x' resolves to 'xxx.x.x.x';
    [Note] Server socket created on IP: 'xxx.x.x.x'.
    [ERROR] Unix socket lock file is empty /opt/bitnami/mysql/tmp/mysql.sock.lock.
    [ERROR] Unable to setup unix socket lock file.
    [ERROR] Aborting
    

    Originally I thought the SSL thing was the issue but someone else pointed out that this is just a warning.

    Ultimately I was able to fix this by just backing up the lock file (just in case) and then removing it:

    # Back that thang up
    sudo cp /opt/bitnami/mysql/tmp/mysql.sock.lock /opt/bitnami/mysql/tmp/mysql.sock.lock.backup
    # Remove it
    sudo rm /opt/bitnami/mysql/tmp/mysql.sock.lock
    # Fire it up again
    sudo /opt/bitnami/ctlscript.sh start mysql