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.