Friday, September 7, 2007

MySQL Installation - Issues

Finally, I came up with some fix for MySQL installation problem of "mysql.host" does not exist.

Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist(we can find this info in /var/log/mysqld.log)

Follow the following steps, MySQL will be installed(all wrt Linux)

1. shell > rm -rf /var/lib/mysql

2. Install mysql rpms.

3. Go to directory where mysql binaries are installed(mysqld_safe, mysql etc)

4. ./mysql_install_db --user=mysql --ldata=/mysqldata (where mysqldata is my data directory for MySQL database. datadir can be specified in /etc/my.cnf file, then we can ignore here)

If it gives a message that hostname is not set or conflict in hostname, then use
./mysql_install_db --user=mysql --ldata=/mysqldata --force

5. MySQL is installed, start MySQL server now,
./mysqld_safe --user=mysql &

Congrats, MySQL is up and running....

When MySQL is Installed, MySQL client does not have any password. It will contain four users, root@localhost, root@localhost.localdomain, ''@localhost, ''@localhost.localdomain('' - anonymous user).
Delete all users at localhost.localdomain and all anonymous users. Set password for root@localhost using

shell > mysql

mysql > drop user root@localhost.localdomain;

mysql > drop user ''@localhost;

mysql > drop user ''@localhost.localdomain;

mysql > set password for root@localhost = password('mysqlroot');

mysql > flush privileges;

mysql > \q

shell >

Flush Privileges will tell server that password is set for root.

MySQL is installed and password is set for mysql client.


@ Koteswara sarma

No comments: