MySQL DBA Tips Corner |
Notes on mysql_install_db - (Release 3.23)
by Jeff Hunter, Sr. Database Administrator
Introduction
While attempting to run mysql_install_db, you notice that
it doesn't install the grant tables and terminates with the
following messages:
In this case, you probably don't have to run mysql_install_db at
all. You have to run mysql_install_db only once, when you install
MySQL for the first time.
This can happen when you already have an existing MySQL installation, but want
to put a new installation in a different place (for example, for testing, or perhaps
you simply want to run two installations at the same time). Generally the problem
that occurs when you try to run the second server is that it tries to use the same
socket and port as the old one. In this case you will get the error message:
Can't start server: Bind on TCP/IP port: Address already in use or Can't
start server: Bind on unix socket...
If you don't have write access to create a socket file at the default
location (in /tmp) or permission to create temporary files
in /tmp, you will get an error when running mysql_install_db
or when starting or using mysqld.
You can specify a different socket and temporary directory as follows:
If you are running RedHat 5.0 with a version of glibc
older than 2.0.7-5, you should make sure you have installed all
glibc patches.
From mysql, manually execute the SQL commands in mysql_install_db.
Make sure you run mysqladmin flush-privileges or mysqladmin reload
afterward to tell the server to reload the grant tables.
Copyright (c) 1998-2013 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
The mysql_install_db script is used to create the MySQL grant
tables with default privileges. This script is usually executed only
once, when first installing MySQL on the system. The
mysql_install_db script creates the
Problems Running mysql_install_db
mysql
database which will hold all database and user privileges, the
test database which you can use to test MySQL,
and also privilege entries for the user that run
mysql_install_db and a root user
(without any passwords).
This section lists the problems you might encounter when attempting to run
the mysql_install_db script:
Keep in mind that you can start mysqld manually using the
--skip-grant-tables option and add the privilege information
yourself using mysql:
starting mysqld daemon with databases from xxxx
mysql daemon ended
In this case, you should examine the log file. The log should be
located in the directory xxxx named by the error message, and
should indicate why mysqld didn't start.
% TMPDIR=/some_tmp_dir/
% MYSQL_UNIX_PORT=/some_tmp_dir/mysqld.sock
% export TMPDIR MYSQL_UNIX_PORT
$ BINDIR/safe_mysqld --skip-grant-tables &
$ BINDIR/mysql -u root mysql
Monday, 25-Jul-2005 20:14:51 EDT
Page Count: 7321