November 20, 2009

Centos 5.4 mysql-server install problem

I ran into a problem installing mysql-server on Centos 5.4. I did the usual

[root@myserver]# yum install mysql-server

The installation works, but this error appears when trying to start mysqld

[root@myserver]# service mysqld start
Initializing MySQL database: Installing MySQL system tables…
ERROR: 1004 Can’t create file ‘/tmp/#sql30e0_1_0.frm’ (errno: 13)
091119 20:43:10 [ERROR] Aborting

091119 20:43:10 [Note] /usr/libexec/mysqld: Shutdown complete

Installation of system tables failed!

Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/libexec/mysqld –skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql
mysql> show tables

Try ‘mysqld –help’ if you have problems with paths. Using –log
gives you a log in /var/lib/mysql that may be helpful.

The latest information about MySQL is available on the web at

http://www.mysql.com

Please consult the MySQL manual section: ‘Problems running mysql_install_db’,
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
[FAILED]

The problem was with SELinux. Issuing

[root@myserver]# sestatus

shows SELinux is enabled and in enforcing mode.

[root@myserver]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted

Disabling SELinux enforcing temporarily allowed the install to proceed.

First we take out the old mysql-server install (the tables weren’t written to correctly):

[root@myserver]# yum remove mysql-server

Make sure mysqld is not running:

[root@myserver]# service mysqld stop

Then we move the corrupt mysql tables out of the way:

[root@myserver]# mv /var/lib/mysql/* /home/some-where-safe/

Next, we set SELinux to permissive mode:

[root@myserver]# setenforce 0

and check that it is so

[root@myserver]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: enforcing
Policy version: 21
Policy from config file: targeted

Now we reinstall mysql-server

[root@myserver]# yum install mysql-server

and start it:

[root@melstar mysql]# service mysqld start
Initializing MySQL database: Installing MySQL system tables…
OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h melstar.theplanet.host password ‘new-password’

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com
[ OK ]
Starting MySQL: [ OK ]

The initialisation proceeded correctly, so we can re-enable SELinux enforcing mode.

[root@myserver]# setenforce 1

and then move on to securing and configuring mysql.

Comments are closed.