Error fatal: no se pueden abrir y bloquear tablas de privilegios: la tabla '' no existe

I am on a server that has afresh install on RHEL 5. I was able to install Apache and PHP just fine., but I am having serious trouble with my MySQL installation. I tried the following:

yum install mysql-server mysql 

And didn't get any errors or conflicts. Then I tried to start mysql with the following commands:

chkconfig --levels 235 mysqld on
service mysqld start

Y obten Timeout error occurred trying to start MySQL Daemon.

I checked my logs and see this error:

[ERROR] Fatal error: Can't open and lock privilege tables: Table '' doesn't exist

No estoy seguro de a dónde ir desde aquí.

For reference I am using RHEL 5 and installed the latest versions of PHP 5 and Apache.

preguntado el 31 de enero de 12 a las 16:01

So I'm searching the mysql site and see that this error message pops up for their troubleshooting on installing mysql on windows systems: OK, that's probably the same problem on a unix based system as well, so i guess I need to figure out what the default location is uspposed to be, and where it's actually being installed. "These messages often occur when the MySQL base or data directories are installed in different locations than the default locations" -

For osx and mysql 5.7, refer to -

18 Respuestas

Después chown y chgrp'En g /var/lib/mysql per the answer by @Bad Programmer, you may also have to execute the following command:

sudo mysql_install_db --user=mysql --ldata=/var/lib/mysql

Luego reinicie su mysqld.

Respondido el 05 de diciembre de 17 a las 15:12

This may be an extremeley stupid question, but define "do"? I ask because the # suggests to me that this is a commented out line in some configuration file and not a command to be entered into terminal. Is that wrong? - Michael

La # indicates to run the command as root (# is the traditional root user shell prompt character, while $ is for unprivileged users). - bk0

./bin/mysqld: Too many arguments (first extra is '–-user=mysql'). - deathangel908

After a fresh install of mysql (or after you delete /var/lib/mysql), you need to manually create the system tables via mysql_install_db. The mysql daemon will not do it for you on startup. - bk0

For anyone else wondering, copy pasting this part seems to fail. I think there's a special character or something in there, so I had to copy by hand. - Ivorius

  1. Uninstall mysql using yum remove mysql*

  2. Recursively delete /usr/bin/mysql y /var/lib/mysql

  3. Eliminar el archivo /etc/my.cnf.rmp

  4. Utilizan ps -e to check the processes to make sure mysql isn't still running.

  5. Reboot server with reboot

  6. Corral yum install mysql-server. This also seems to install the mysql client as a dependency.

  7. Give mysql ownership and group priveleges with:

    chown -R mysql /var/lib/mysql

    chgrp -R mysql /var/lib/mysql

  8. Utilizan service mysqld start to start MySQL Daemon.

contestado el 15 de mayo de 15 a las 03:05

I think changing group and ownership was the vital part. It seems that when mysql starts it automatically creates the mysql.sock file, but it can't do that if it doesn't have system permissions. - Mal programador

I wonder if SELinux permissions might also have been involved? Destroying the whole thing might have let the relabeling daemon label the new files with the correct labels. - sarnold

I've reproduced this error and the chgrp statement alone was enough to resolve it. - Travis Jensen

This answer should be edited to include @bk0 answer between steps 7 and 8. That's how a got my mysql (mariadb on centOS 7) sorted out. - L. Holanda

Got the same error message, but changing the permissions did not fix the problem. Any thoughts? - Michael

I had this issue on arch linux as well. The issue was pacman installed the package in a different location than MySQL was expecting. I was able to fix the issue with this:

sudo mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/

Espero que esto ayude a alguien!

Respondido 22 Abr '16, 23:04

I even don't knowed this command, it works indeed with mariadb and on a current Debian system - normico

The root of my problem seemed to be selinux, which was turned on (enforcing) automatically on OS install.

I wanted my mysql in /data.

After verifying that my.cnf had:


(and leaving the socket at /var/lib/mysql) I executed the command to turn off selinux for mysqld (alternative is to turn it off completely):

setsebool -P mysqld_disable_trans=1

I ran the following commands:

> chown -R mysql .
> chgrp -R mysql .
> mysql_install_db --user=mysql

I started the mysql daemon and everything worked fine after that.

Respondido el 19 de diciembre de 12 a las 04:12

mysql_install_db –-user=mysql --ldata=/var/lib/mysql

Worked for me in Centos 7

Respondido 28 ago 19, 15:08

If applicable, I find this a much better solution than completely uninstalling and reinstalling the database server like other answers are suggesting. - Jestep

Solved my problem ,and actually this command should be run under mysql directory as : ./scripts/mysql_install_db --user=mysql –ldata=/var/lib/mysql - CobraBJ

initialize mysql before start on windows.

mysqld --initialize

Respondido el 21 de diciembre de 15 a las 12:12

[ERROR] --initialize specified but the data directory has files in it. Aborting. - giannis christofakis

@giannischristofakis If it's a brand new install -- no actual database with valuable data, just delete the contents of the data directory and reissue the command. (2 years later.) - rana

@giannischristofakis What if it's not a brand new install? - mal

When download mysql zip version, if run mysqld directly, you'll get this error: 2016-02-18T07:23:48.318481Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 2016-02-18T07:23:48.319482Z 0 [ERROR] Aborting

You have to run below command first: mysqld --initialize

Make sure your data folder is empty before this command.

Respondido 18 Feb 16, 10:02

I just met the same problem with mysql 5.7 on OSX:

rm -rf {datadir}
mysqld --initialize --datadir {datadir}
mysqld --datadir {datadir}

Respondido el 07 de junio de 16 a las 03:06

If you move your datadir, you not only need to give the new datadir permissions, but you need to ensure all parent directories have permission.

I moved my datadir to a hard drive, mounted in Ubuntu as:


and my datadir was Bases de datos.

I had to set permissions to 771 to each of the media, usuario and Data directories:

sudo chmod 771 *DIR*

If this does not work, another way you can get mysql to work is to change user in /etc/mysql/my.cnf to root; though there are no doubt some issues with doing that from a security perspective.

Respondido el 01 de diciembre de 15 a las 04:12

For myself, I had to do:

yum remove mysql*

rm -rf /var/lib/mysql/
cp /etc/my.cnf ~/my.cnf.bkup

yum install -y mysql-server mysql-client


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

service mysql start

Then I was able to get back into my databases and configure them again after I nuked them the first go around.

Respondido el 06 de Septiembre de 13 a las 22:09

This is the one that did it for me. mysql_install_db wasn't enough, but this solved for me. Thanks. - pez porcino

Just this command is enough to do the magic on centos 6.6


Respondido 20 Feb 16, 09:02

In my case the path of MySQL data folder had a special character "ç" and it make me get...

Fatal error: Can't open and lock privilege tables: Table '' doesn't exist.

I'm have removed all special characters and everything works.

Respondido el 26 de junio de 13 a las 23:06

On CentOS EL 6 and perhaps on earlier versions there is one way to get into this same mess.

Install CentOS EL6 with a minimal installation. For example I used kickstart to install the following:


You will find that one of the dependencies of the above list is mysql-libs. I found that my system has a default my.cnf in /etc and this contains:

# Disabling symbolic-links is recommended to prevent assorted security risks


When you build from the Generic Linux (Architecture Independent), Compressed TAR Archive your default data directory is /usr/local/mysql/data which conflicts with the /etc/my.cnf already present which defines datadir=/var/lib/mysql. También el pid-file defined in the same file does not have permissions for the mysql user/group to write to it in /var/run/mysqld.

A quick remedy is to mv /etc/my.cnf /etc/my.cnf.old which should get your generic source procedure working.

Of course the experience is different of you use the source RPMs.

Respondido el 10 de diciembre de 13 a las 03:12

I had the same issue in trying to start the server and followed the "checked" solution. But still had the problem. The issue was the my /etc/my.cnf file was not pointing to my designated datadir as defined when I executed the mysql_install_db with --datadir defined. Once I updated this, the server started correctly.

Respondido 21 Abr '14, 04:04

If you have a server which used to happily run MySQL, but now gives this error, then an uninstall and re-install of MySQL is overkill.

In my case, the server died and took a few disk blocks with it. This affected a few files, including /var/lib/mysql/mysql/host.frm and /var/lib/mysql/mysql/proc.frm

Luckily, I could copy these from another server, and this got me past that table error.

Respondido el 07 de diciembre de 16 a las 15:12

I got similar error on overlayfs (overlay2) that is the default on Docker for Mac. The error happens when starting mysql on the image, after creating a image with mysql.

2017-11-15T06:44:22.141481Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table storage engine for 'user' doesn't have this option

Switching to "aufs" solved the issue. (On Docker for Mac, the "daemon.json" can be edited by choosing "Preferences..." menu, and selecting "Daemon" tab, and selecting "Advanced" tab.)

/etc/docker/daemon.json :

  "storage-driver" : "aufs",
  "debug" : true,
  "experimental" : true


respondido 15 nov., 17:10

In Windows run the following commands in the command prompt as adminstrator

Step 1:

Step 2:
mysqld --initialize

Step 3:
mysqld --console

Step 4:
In windows

Step 4:
mysqladmin -u root password "XXXXXXX"

Step 5:
mysql -u root -p

Mariadb database information

Respondido 29 ago 20, 04:08

My case on Ubuntu 14.04.2 LTS was similar to others with my.cnf, but for me the cause was a ~/.my.cnf that was leftover from a previous installation. After deleting that file and purging/re-installing mysql-server, it worked fine.

Respondido 05 Jul 15, 07:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.