Mysql startup prompt mysql. host does not exist, startup failed

Source: Internet
Author: User
Tags mysql in

But for the first time I touched mysql, I did not understand it.
Now, let's talk about the process of solving the problem:

Follow the mysql installation steps:
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:
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:
Shell> scripts/mysql_install_db -- user = mysql -- datadir =/u01/mysql/data
This solves the problem.
This problem also occurs when you change the data files of your database to another directory, because you have not created a database permission table in the corresponding directory, the solution is to re-run the mysql_install_db file to regenerate the database permission table, but you also need to re-create the user and set permissions; the second method should be to copy the files in the old permission table to the corresponding database table directory first, but the second method I did not use is just based on my own imagination. If you have a master, check whether the master is correct.

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.