MySQL failed to start: Table Mysql.host doesn t exist

Source: Internet
Author: User
Tags mysql in

Tips:

Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

Checked MySQL log (cat/var/log/mysqld.log) found prompt for an error ([ERROR] Fatal Error:can ' t open and Lock privilege tables:table ' Mysql.host ' doesn ' t exist), as shown in figure:

Speculation may be MySQL's default database is not installed normally, but uninstall MySQL (yum remove mysql-server) reload (yum install mysql-server) or not, the phenomenon is the same as the original. Later, we found a command to install the default database specifically: mysql_install_db, after the execution, and then start MySQL (/etc/init.d/mysqld start) finally see a long absence of OK:

The code is as follows Copy Code

#/etc/init.d/mysqld Start
Starting MySQL: [OK]


Question Two

When started with the SAFE_MYSQLDQ, it appears

Fatal Error:can ' t open and Lock Privilege tables:table ' mysql.host ' doesn ' t exist

The final solution is as follows:

Under the MySQL installation directory, mine is/usr/local/mysql.

The code is as follows Copy Code

./scripts/mysql_install_db--usrer=mysql--datadir=/usr/local/mysql/data/

The reason is that the data directory inconsistency caused by the reload


Question Three

Tell me about the process I solved:

Follow the MySQL installation steps:

  code is as follows copy code
shell> Groupadd MySQL
shell> useradd-g mysql mysql
shell> gunzip < mysql-version.tar.gz | tar-xvf-
She ll> CD mysql-version
shell>./configure--prefix=/usr/local/mysql
shell> make
shell> make Insta ll
shell> scripts/mysql_install_db--user=mysql
shell> chown-r root/usr/local/mysql
shell> chown -R mysql/usr/local/mysql/var
shell> chgrp-r mysql/usr/local/mysql
shell> CP support-files/my-medium.cn F/ETC/MY.CNF
shell>/usr/local/mysql/bin/mysqld_safe--user=mysql &

There is no problem with this standard, but when I start MySQL in the final step I want to put the data files of the database under another directory, and the start command is modified to:

The code is as follows Copy Code
Shell>/usr/local/mysql/bin/mysqld_safe--user=mysql--log-error=/u01/mysql/mysql_error/error--datadir=/u01/ Mysql/data

There is a problem at this time, because the default created permission table is below the default directory/usr/local/mysql/var when you initialize the Database permission table, which causes the above error to not find the permission table: Can ' t open and lock Privilege tables:table ' mysql.host ' doesn ' t exist

Workaround use the Add parameter--datadir when running the initialization permission table, the command format is:

The code is as follows Copy Code
shell> scripts/mysql_install_db--user=mysql--datadir=/u01/mysql/data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.