Mysql – Why can I not start thesqld_safe on Red Hat Enterprise Linux (RHEL)

MySQLredhatrhel4

I downloaded mysql-5.1.44.tar.gz and installed it by issuing the following commands:

$ ./configure
$ make
$ make install

Everything installed without any error. Next, I tried to start the mysql server by issuing the following command:

$ mysqld_safe --user=mysql &
100310 13:25:56 mysqld_safe Logging to '/usr/local/var/perfportal2.err'.
100310 13:25:56 mysqld_safe Starting mysqld daemon with databases from /usr/local/var
100310 13:25:56 mysqld_safe mysqld from pid file /usr/local/var/perfportal2.pid ended

$ cat /usr/local/var/myserver.err 
100310 13:25:56 mysqld_safe Starting mysqld daemon with databases from /usr/local/var
/usr/local/libexec/mysqld: Table 'mysql.plugin' doesn't exist
100310 13:25:56 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
100310 13:25:56 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
100310 13:25:56 mysqld_safe mysqld from pid file /usr/local/var/perfportal2.pid ended

My guess is the installation process did not create the data directory.

Any suggestions about what I should do?

Best Answer

If you ran make install and already had the mysql-server package installed, chances are you had a pre-existing mysql database schema in /var/lib/mysql. The version included with RHEL5 is 5.0.77, which could explain the mysql-upgrade error, as that script updates the schema between MySQL versions. The error could also be very similar if you did not create the initial schema as part of your installation.

If you're going to compile from source and not specify installation locations, you need to remove the system packages of mysql first. If you want to maintain both the system packages and the source installation, which there is sometimes argument for, you need to be careful not to stomp all over the system package. That typically means installing your source in a location such as /usr/local/mysql as opposed to the default of /usr/local. You can accomplish this with ./configure --prefix=/usr/local/mysql. There are more details here and best practices that I'm not going to elaborate further on.

While there can be good reasons to compile from source, you might reconsider yours, as it may not be necessary for you.

rpm -qa | grep mysql will display all packages currently installed. Probably mysql-server and mysql-client.

Otherwise, you didn't follow the procedure from the documentation. Even if you did, you will have to repeat it after removing the MySQL packages.

From INSTALL-SOURCE, which was included in the mysql-5.1.44 tarball:

2.3.1. Source Installation Overview

   The basic commands that you must execute to install a MySQL source
   distribution are:
shell> groupadd mysql
shell> useradd -g mysql 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> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &
Related Topic