Search the MySQL manual:

2.4.2 Problems Starting the MySQL Server

If you are going to use tables that support transactions (InnoDB, BDB), you should first create a `my.cnf' file and set startup options for the table types you plan to use. See section 7 MySQL Table Types.

Generally, you start the mysqld server in one of these ways:

When the mysqld daemon starts up, it changes the directory to the data directory. This is where it expects to write log files and the pid (process ID) file, and where it expects to find databases.

The data directory location is hardwired in when the distribution is compiled. However, if mysqld expects to find the data directory somewhere other than where it really is on your system, it will not work properly. If you have problems with incorrect paths, you can find out what options mysqld allows and what the default path settings are by invoking mysqld with the --help option. You can override the defaults by specifying the correct pathnames as command-line arguments to mysqld. (These options can be used with mysqld_safe as well.)

Normally you should need to tell mysqld only the base directory under which MySQL is installed. You can do this with the --basedir option. You can also use --help to check the effect of changing path options (note that --help must be the final option of the mysqld command). For example:

shell> EXECDIR/mysqld --basedir=/usr/local --help

Once you determine the path settings you want, start the server without the --help option.

Whichever method you use to start the server, if it fails to start up correctly, check the log file to see if you can find out why. Log files are located in the data directory (typically `/usr/local/mysql/data' for a binary distribution, `/usr/local/var' for a source distribution, and `\mysql\data\mysql.err' on Windows). Look in the data directory for files with names of the form `host_name.err' and `host_name.log' where host_name is the name of your server host. Then check the last few lines of these files:

shell> tail host_name.err
shell> tail host_name.log

Look for something like the following in the log file:

000729 14:50:10  bdb:  Recovery function for LSN 1 27595 failed
000729 14:50:10  bdb:  warning: ./test/t1.db: No such file or directory
000729 14:50:10  Can't init databases

This means that you didn't start mysqld with --bdb-no-recover and Berkeley DB found something wrong with its log files when it tried to recover your databases. To be able to continue, you should move away the old Berkeley DB log file from the database directory to some other place, where you can later examine it. The log files are named `log.0000000001', where the number will increase over time.

If you are running mysqld with BDB table support and mysqld core dumps at start this could be because of some problems with the BDB recover log. In this case you can try starting mysqld with --bdb-no-recover. If this helps, then you should remove all `log.*' files from the data directory and try starting mysqld again.

If you get the following error, it means that some other program (or another mysqld server) is already using the TCP/IP port or socket mysqld is trying to use:

Can't start server: Bind on TCP/IP port: Address already in use
  or
Can't start server : Bind on unix socket...

Use ps to make sure that you don't have another mysqld server running. If you can't find another server running, you can try to execute the command telnet your-host-name tcp-ip-port-number and press Enter a couple of times. If you don't get an error message like telnet: Unable to connect to remote host: Connection refused, something is using the TCP/IP port mysqld is trying to use. See section 2.4.1 Problems Running mysql_install_db and section 4.1.3 Running Multiple MySQL Servers on the Same Machine.

If mysqld is currently running, you can find out what path settings it is using by executing this command:

shell> mysqladmin variables

or

shell> mysqladmin -h 'your-host-name' variables

If you get Errcode 13, which means Permission denied, when starting mysqld this means that you didn't have the right to read/create files in the MySQL database or log directory. In this case you should either start mysqld as the root user or change the permissions for the involved files and directories so that you have the right to use them.

If mysqld_safe starts the server but you can't connect to it, you should make sure you have an entry in `/etc/hosts' that looks like this:

127.0.0.1       localhost

This problem occurs only on systems that don't have a working thread library and for which MySQL must be configured to use MIT-pthreads.

If you can't get mysqld to start you can try to make a trace file to find the problem. See section E.1.2 Creating Trace Files.

If you are using InnoDB tables, refer to the InnoDB-specific startup options. See section 7.5.3 InnoDB Startup Options.

If you are using BDB (Berkeley DB) tables, you should familiarise yourself with the different BDB-specific startup options. See section 7.6.3 BDB startup options.

User Comments

Posted by Scott Deardorff on Tuesday January 29 2002, @8:30am[Delete] [Edit]

When compiling with the patched Berkely DB 3.1.17 there is a compile error in hash.h problem is that it is reading hash.h from the mysql directory instead of the proper hash.h in the Berkely DB directory. To fix this add -I$(srcdir)/include IN FRONT OF -I/usr/local/src/mysql-3.23.24-beta/include in the ../db-3.1.17-patched/build_unix/Makefile on the CFLAGS and CXXFLAGS lines. After this it compiles past this point.

Posted by geert declercq on Tuesday January 29 2002, @8:30am[Delete] [Edit]

I wanted to give my SUN ELC/25 (16 MB memory - 32 MB swap) a second life; installed red hat linux 6.2 on it and I'm now installing mysql from the source : it's been running for more then 14 hours (yes, hours) now ... - when inspecting some of the compilation processes with top, it looks that the compilation process takes quite some naps every couple of seconds (sleep state).

Posted by Robert C. Henney on Tuesday January 29 2002, @8:30am[Delete] [Edit]

On BSDI 4.0.1, I had to append a line containing just "mi_test_all:" to end of the myisam/Makefile file after the ./configure step. Otherwise the make step would fail. ALSO, on BSDI 4.2 using gcc 2.95.2 I had to add an explicit "(size_t*)" before the 5th argument to the getsockopt() call in sql/mini_client.cc on line 297 or gcc would abort with a "changing signedness" error.

Posted by [name withheld] on Tuesday January 29 2002, @8:30am[Delete] [Edit]

<a
href="http://www.devshed.com/Server_Side/PHP/Sooth
inglySeamless/">The Soothingly Seamless Setup of
Apache, SSL, MySQL, and PHP</a> -Jim

Posted by Justin Clift on Wednesday December 18 2002, @5:27pm[Delete] [Edit]

Another Open Source benchmark tool/suite for benchmarking both MySQL and
PostgreSQL (and Informix, hopefully Interbase soon too) is the Open Source Database
Benchmark.

<a href="http://osdb.sourceforge.net"
target="_blank">http://osdb.sourceforge.net</a>

At the time of posting this (20th September 2001) the CVS code has been heavily
modified, so it's probably best to use that instead of the latest release.

Posted by davidhj on Tuesday January 29 2002, @8:30am[Delete] [Edit]

If your error log file has something like:

Can't find file: './mysql/host.frm' (errno: 13)

, and you've tried setting
--datadir=/path/to/my/data/directory but you
still get the same error, it may be because the
databases installed in the mysql data directory
(usually /var/lib/mysql) are not owned by the
mysql daemon, but by the user who ran
mysql_install_db. chown them to mysql and chgrp
them to the appropriate group e.g.

chown -R mysql /var/lib/mysql/mysql
chgrp -R daemons /var/lib/mysql/mysql



Add your own comment.