简体   繁体   中英

SQLSTATE[HY000]: General error: 13 Can't get stat of './pics' (Errcode: 13 - Permission denied)

I was working on my ubuntu 16.0.4 server, on a Symfony 3.4 app. I accidentaly did a bad manipulation

sudo chown -R USER /var/

While I wanted to enter :

sudo chown -R USER var/

Since then, I can't access to my database.

My Symfony App says me :

An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database 'pics'

And using doctrine, trying to create a new database, I have this error :

SQLSTATE[HY000]: General error: 13 Can't get stat of './pics' (Errcode: 13 - Permission denied)

I don't know how my database could be deleted like this.

Can somebody help me ?

If you updated the user on /var , then the /var/lib/mysql directory is owned by the wrong user, and the mysqld process cannot write to that directory (and possibly not read it).

You can likely restore permissions for the database by:

cd /var/lib
chown -R mysql:mysql mysql

(Note: assuming the use of the default process owner and default directory locations)

I would likely then restart the mysql process.

However, you may have multiple other issues, including /var/run not having all of the correct owners, and thus while the system may be semi-stable at the moment, a reboot could fail very badly.

While one can, as a comment noted, by-pass the issue by allowing full read-write via a chmod 777 , that simply opens the system in a way that is not secure. By losing the permission sets, you would have added another layer of problems.

The correct approach is to fix the ownership of all the directories in the /var hierarchy. Possibly comparing against a known good system would provide the correct owners. But for the database the above will give access again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM