MySQL cannot be started: Tablemysql. hostdoesntexist

Source: Internet
Author: User
MySQL cannot be started: Tablemysql. hostdoesntexist. The following describes how to solve this problem. The installation was successful but failed to start. I thought it was possible that I had misoperated the permissions of the var Directory, resulting in no write permission. However, after you reset the write permission, it cannot be started correctly.

MySQL cannot be started: Table \ 'MySQL. host \ 'doesn \'t exist. The following describes how to solve this problem. The installation was successful but failed to start. I thought it was possible that the permission for the/var/directory was incorrect, resulting in no write permission. However, after you reset the write permission, it cannot be started correctly.

Tip:

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

Check MySQL logs (cat/var/log/mysqld. log) an ERROR ([error] Fatal ERROR: Can't open and lock privilege tables: Table 'MySQL. host 'doesn' t exist ),

It is suggested that the default MySQL database is not properly installed, but it still fails to uninstall MySQL (yum remove mysql-server) and reinstall (yum install mysql-server). The phenomenon is the same as the original one. Then I found a command dedicated to installing the default database: mysql_install_db. after executing the command, I started MySQL (/etc/init. d/mysqld start) and finally saw the long-overdue OK:

The code is as follows:

#/Etc/init. d/mysqld start
Starting MySQL: [OK]


Question 2

When you start with safe_mysqldq

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

The final solution is as follows:

In the installation directory of mysql, my options are/usr/local/mysql.

The code is as follows:

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

This error is caused by inconsistent data directories during reinstallation.


Question 3

Let's talk about the solution process:

Follow the mysql installation steps:

The code is as follows:
Shell> groupadd mysql
Shell> useradd-g mysql
Shell> gunzip | mysql-VERSION.tar.gz | tar-xvf-
Shell> cd mysql-VERSION
Shell>./configure -- prefix =/usr/local/mysql
Shell> make
Shell> make install
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
Shells> cp support-files/my-medium.cnf/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 last step, I want to put the database data file under another directory and change the startup command:

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

This problem occurs because the permission table created by default is under the default directory/usr/local/mysql/var when initializing the database permission table, this leads to the failure to find the permission Table: Can't open and lock privilege tables: Table 'MySQL. host 'doesn' t exist

Solution: when you run the initialization permission table, add the parameter datadir. the command format is as follows:

The code is as follows:
Shell> scripts/mysql_install_db -- user = mysql -- datadir =/u01/mysql/data

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.