Search the MySQL manual:
MySQL Manual

Buy this Reference Manual in softcover from Barnes & Noble!

/ / Up / Table of Contents

2.4.2 Проблемы при запуске сервера MySQL

Если вы собираетесь использовать таблицы, поддерживающие транзакции (InnoDB, BDB), следует прежде всего создать файл `my.cnf' и установить опции запуска для тех типов таблиц, с которыми планируется работать. See section 7 Типы таблиц MySQL.

В общем случае сервер mysqld запускается одним из следующих способов:

При своем запуске демон mysqld изменяет свой каталог на каталог данных (datadir). В нем он ожидает найти журнальные файлы, файлы pid (ID процессов) и собственно базы данных.

Местоположение каталога данных жестко устанавливается при компиляции дистрибутива. Однако если mysqld ожидает найти каталог данных где-либо в другом месте, а не там, где он действительно расположен в вашей системе, то демон mysqld не будет работать правильно. Если есть проблемы с неправильными путями, то, вызывая mysqld с опцией --help, вы можете найти информацию о том, что разрешают опции mysqld и какие установки путей приняты по умолчанию. Можно переопределить установки по умолчанию указанием правильных имен путей как аргументов mysqld в командной строке (эти опции также можно использовать с safe_mysqld).

Обычно требуется указывать mysqld только каталог, в котором устанавливается MySQL. Это можно сделать с помощью опции --basedir. Можно также использовать --help для проверки эффекта от изменения опций путей (учтите, что --help должна быть последней опцией в команде mysqld). Например:

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

После определения требуемых установок путей запускайте сервер без опции --help.

Какой бы метод вы ни использовали для запуска сервера, если его неудачный запуск завершается корректно, то проверьте журнальный файл, чтобы узнать, почему запуск происходит неудачно. Журнальные файлы находятся в каталоге данных (обычно `/usr/local/mysql/data' для бинарного дистрибутива, `/usr/local/var' для дистрибутива исходного кода и `\mysql\data\mysql.err' под Windows). В каталоге данных следует искать файлы с именами в виде `host_name.err' и `host_name.log', где host_name - имя вашего серверного хоста. Затем проверьте последние несколько строк этих файлов:

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

В журнальном файле нужно искать что-нибудь похожее на следующее:

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

Это означает, что вы не запустили mysqld с --bdb-no-recover и база данных Berkeley DB нашла что-то ошибочное в своих журнальных файлах при попытке восстановить ваши базы данных. Чтобы иметь возможность продолжить, необходимо переместить старый журнальный файл Berkeley DB из каталога баз данных в некоторое другое место, где позже можно будет изучить его. Журнальные файлы имеют имена `log.0000000001' и т.д.; номер возрастает при каждом запуске.

Если вы запускаете mysqld работает с поддержкой таблиц BDB и mysqld при старте выводит дамп оперативной памяти (coredump), то причиной этого это могут быть какие-либо проблемы с журналом восстановления BDB. В этом случае можно попробовать запуск mysqld с --bdb-no-recover. Если это помогает, то следует удалить все файлы `log.*' из каталога данных и попробовать запустить mysqld опять.

Если выдается приведенная ниже ошибка, то это означает, что некоторая другая программа (или другой сервер mysqld) уже использует данный TCP/IP порт или сокет, на которых mysqld пытается слушать:

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

Чтобы убедиться, что другого работающего сервера mysqld нет, используйте ps. Если другой работающий сервер не найден, то можно попробовать выполнить команду telnet your-host-name tcp-ip-port-number и нажать пару раз клавишу ``Enter''. Если вы не получаете сообщения об ошибке вроде следующего telnet: Unable to connect to remote host: Connection refused, значит, что порт TCP/IP порт, который mysqld пытается использовать, уже занят другой программой. section 2.4.1 Проблемы при запуске mysql_install_db и раздел See section 4.1.4 Запуск нескольких серверов MySQL на одном компьютере.

Если mysqld в настоящее время работает, то можно найти используемые им установки путей при помощи следующей команды:

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

Если при запуске mysqld вы получили ошибку Errcode 13, что значит Permission denied, это означает, что у вас не было прав читать/создавать файлы в базе данных MySQL или в журнальном каталоге. В таком случае вам следует либо запускать mysqld как пользователь root, либо изменить права доступа к упомянутым файлам и каталогам, чтобы иметь права использовать их.

Если safe_mysqld запускает сервер, но вы не можете подключиться к нему, то следует убедиться, что в `/etc/hosts' есть запись, которая выглядит примерно так:

127.0.0.1 localhost

Эта проблема возникает только в системах, не имеющих рабочей библиотеки потоков, и для которых MySQL следует конфигурировать для использования потоков MIT-pthreads.

Если вы не можете запустить mysqld, то можно попробовать создать трассировочный файл, чтобы обнаружить данную проблему. See section E.1.2 Создание трассировочных файлов.

При использовании таблиц InnoDB следует указывать опции запуска, специфические для InnoDB. See section 7.5.2 Параметры запуска InnoDB.

При использовании таблиц BDB (Berkeley DB) необходимо хорошо знать различные специфические для BDB опции запуска. See section 7.6.3 Параметры запуска BDB.

User Comments

Posted by 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 on Tuesday January 29 2002, @8:30am [Delete] [Edit]

For FreeBSD (I'm using 4.1.1), startup scripts generally should go in /usr/local/etc/rc.d/

man rc
indicates that "Scripts are only executed if their basename matches the shell globbing pattern *.sh"

In other words, copy support-files/mysql.server to /usr/local/etc/rc.d/mysql.server.sh
to enable auto-starting for FreeBSD

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

I am unable to update multiple records using a
single quiries or even by executing servral
update statement in a row.

The problem comes only when I try to execute the
update statement through PERL DBI(I am using
Active Perl on Windows). It is effecting only
the only the first record not updating the other
records on the list. The same statement works
fine when executed directly on MYSQL.

The quireies I have used are
1. update ind_list set ind_stat="y" where ind_id
in (001, 002, 003, 004, 005,006,007,008);

2. update in_list set ind_stat="y" where
(ind_id=001) or (ind_id=002) or (ind_id=003) or
(ind_id=004) or (ind_id=005) or (ind_id=006) or
(ind_id=007) or (ind_id=008)

3. This in a loop changing the id values
update ind_list set ind_stat="y" where
ind_id="001".

Posted by 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 Matt Nicolls on Tuesday January 29 2002, @8:30am [Delete] [Edit]

Let's say you have two tables with related
records. Your application requires that you
update table 1, then update the related record in
table 2. However, the rule also states that both
tables must be updated or the transaction should
be cancelled.

I update table 1 successfully, then attempt to
update table 2 - but it fails... What good is
table locking?

This section states that the cost of supporting
ROLLBACKs is a huge performance hit. It seems to
me that the performance hit (i.e. storing a copy
of the rows you are affecting in the case of a
rollback) would only be incurred if a BEGIN was
issued. If that is the case, than only those who
issue BEGINs will experience the performance hit.

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

I think there is something missing around step 8.
When I run bin/safe_mysqld --user=mysql
I get a message "Starting mysqld daemon with databases from /usr/local/mysql/var"
but then I try to run
bin/mysqladmin -u root -p password
and I always get
bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: YES)'


There must be a way to create an initial password
but it is not documented.

Posted by 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]

href="http://www.devshed.com/Server_Side/PHP/Sooth
inglySeamless/">The Soothingly Seamless Setup of
Apache, SSL, MySQL, and PHP
-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.

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

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 Jerry zavala on Tuesday January 29 2002, @8:30am [Delete] [Edit]

I followed the directions exactly how they are
posted and once I start mysql it automatically
ends. I don't have other mysql servers running.
Any suggestions? where can I find the `mysql-data-
directory/'hostname'.err'?

Posted by 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



Posted by on Monday August 19 2002, @11:47am [Delete] [Edit]

I seem to be having a problem geting mysql server
to start.. I go to where mysqld is ((because I
havnet' set the path yet)) when I try to get it to
start it gives me this:

Initializing MySQL database: Sorry, the host 'dimitri'
could not be looked up. Please configure
the 'hostname' command to return a correct
hostname. If you want to solve this at a later stage,
restart this script with the --force option
FAILED]

dimitri is the servername I have on my server and I
can't figure out why it won't start up. Any help
woudl be appreciated. I ahve checked the entire
forums adn can't find anythign dealing with this.
Please e-mail me or post it in here. ok it isn't
showing my info. So her ei smy e-mail.
[email protected]

Add your own comment.

Top / / / Up / Table of Contents