Can't start MySQL service after permissions issues

7,071

After a suggestion by cargo, I was able to get things working again by giving permission for the root group to access /var/log/mysql. I then restarted the mysql service with sudo service mysql restart and everything was back to normal.

Share:
7,071

Related videos on Youtube

travisw
Author by

travisw

Updated on September 18, 2022

Comments

  • travisw
    travisw over 1 year

    I'm hosting a local LAMP server with Magento installed on it (in /var/www/html/magento), which I've had working fine, but I managed to break some things tonight.

    I encountered an issue with part of my Magento setup (I honestly don't recall what) that prompted me to run chmod -R -777 /var/ and chown -R travis /var/ to give permissions to all the files within.

    This caused Apache 403 errors, which were resolved by me running chmod -R -755 /var/www/ and chown -R root /var/. Further permissions were fixed with chmod -R -777 /var/www/html/magento.

    Fastforward to now

    I can't start my MySQL service. Here's what I'm getting:

    travis@travis: service mysql stop
    travis@travis: service mysql start
    Job for mysql.service failed. See "systemctl status mysql.service" and "journalctl -xe" for details.
    travis@travis:/etc/mysql$ systemctl status mysql.service -l
    ● mysql.service - MySQL Community Server
    Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
    Active: activating (start-post) (Result: exit-code) since Wed 2015-06-17 23:01:24 EDT; 7min ago
    Process: 31638 ExecStart=/usr/bin/mysqld_safe (code=exited, status=2)
    Process: 31635 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Main PID: 31638 (code=exited, status=2);         : 31639 (mysql-systemd-s)
    CGroup: /system.slice/mysql.service
           └─control
             ├─ 1072 sleep 1
             └─31639 /bin/bash /usr/share/mysql/mysql-systemd-start post
    
    Jun 17 23:01:24 travis systemd[1]: Starting MySQL Community Server...
    Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
    Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Logging to '/var/log/mysql/error.log'.
    Jun 17 23:01:24 travis mysqld_safe[31638]: touch: cannot touch ‘/var/log/mysql/error.log’: Permission denied
    Jun 17 23:01:24 travis mysqld_safe[31638]: chmod: cannot access ‘/var/log/mysql/error.log’: Permission denied
    Jun 17 23:01:24 travis mysqld_safe[31638]: 150617 23:01:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    Jun 17 23:01:24 travis mysqld_safe[31638]: /usr/bin/mysqld_safe: 126: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
    Jun 17 23:01:24 travis mysqld_safe[31638]: /usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
    Jun 17 23:01:24 travis systemd[1]: mysql.service: main process exited, code=exited, status=2/INVALIDARGUMENT
    

    Now, my Magento site 127.0.0.1/magento/ displays an error page led with:

    SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)
    
    • cargo
      cargo almost 9 years
      The reinstall route would also save from having to go through this with any other program that is going to have permissions errors. Since it looks like our file systems are different enough I am going to delete the solution I got from mine.
    • travisw
      travisw almost 9 years
      Ok, strange (but pleasant) happenings. All I had to do (above what you had posted) was give the root group permission to Access /var/log/mysql. I then ran sudo service mysql restart successfully and everything is intact. If you'd like to repost your solution as an answer, I'd gladly accept to get you the credit you deserve.
  • travisw
    travisw almost 9 years
    Results in the same error with the same log.
  • Ayushya
    Ayushya almost 9 years
    Ok, I read what happened before the fast-forward ... and that looks bad. Your whole /var permissions have been adjusted. If possible, I would say reinstall the OS.