This is for Mac OS X with the native installation of Apache HTTP and custom installation of MySQL.
The answer is based on @alec-gorge’s excellent response, but since I had to google some specific changes to have it configured in my configuration, mostly Mac OS X-specific, I thought I’d add it here for the sake of completeness.
Enable PHP5 support for Apache HTTP
Make sure the PHP5 support is enabled in /etc/apache2/httpd.conf
.
Edit the file with sudo vi /etc/apache2/httpd.conf
(enter the password when asked) and uncomment (remove ;
from the beginning of) the line to load the php5_module module.
LoadModule php5_module libexec/apache2/libphp5.so
Start Apache HTTP with sudo apachectl start
(or restart
if it’s already started and needs to be restarted to re-read the configuration file).
Make sure that /var/log/apache2/error_log
contains a line that tells you the php5_module is enabled — you should see PHP/5.3.15
(or similar).
[notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch configured -- resuming normal operations
Looking up Socket file’s name
When MySQL is up and running (with ./bin/mysqld_safe
) there should be debug lines printed out to the console that tell you where you can find the log files. Note the hostname in the file name — localhost
in my case — that may be different for your configuration.
The file that comes after Logging to
is important. That’s where MySQL logs its work.
130309 12:17:59 mysqld_safe Logging to '/Users/jacek/apps/mysql/data/localhost.err'.
130309 12:17:59 mysqld_safe Starting mysqld daemon with databases from /Users/jacek/apps/mysql/data
Open the localhost.err
file (again, yours might be named differently), i.e. tail -1 /Users/jacek/apps/mysql/data/localhost.err
to find out the socket file’s name — it should be the last line.
$ tail -1 /Users/jacek/apps/mysql/data/localhost.err
Version: '5.5.27' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
Note the socket:
part — that’s the socket file you should use in php.ini
.
There’s another way (some say an easier way) to determine the location of the socket’s file name by logging in to MySQL and running:
show variables like '%socket%';
Configuring PHP5 with MySQL support — /etc/php.ini
Speaking of php.ini…
In /etc
directory there’s /etc/php.ini.default file. Copy it to /etc/php.ini.
sudo cp /etc/php.ini.default /etc/php.ini
Open /etc/php.ini
and look for mysql.default_socket.
sudo vi /etc/php.ini
The default of mysql.default_socket
is /var/mysql/mysql.sock
. You should change it to the value you have noted earlier — it was /tmp/mysql.sock
in my case.
Replace the /etc/php.ini
file to reflect the socket file’s name:
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
Final verification
Restart Apache HTTP.
sudo apachectl restart
Check the logs if there are no error related to PHP5. No errors means you’re done and PHP5 with MySQL should work fine. Congrats!
This is for Mac OS X with the native installation of Apache HTTP and custom installation of MySQL.
The answer is based on @alec-gorge’s excellent response, but since I had to google some specific changes to have it configured in my configuration, mostly Mac OS X-specific, I thought I’d add it here for the sake of completeness.
Enable PHP5 support for Apache HTTP
Make sure the PHP5 support is enabled in /etc/apache2/httpd.conf
.
Edit the file with sudo vi /etc/apache2/httpd.conf
(enter the password when asked) and uncomment (remove ;
from the beginning of) the line to load the php5_module module.
LoadModule php5_module libexec/apache2/libphp5.so
Start Apache HTTP with sudo apachectl start
(or restart
if it’s already started and needs to be restarted to re-read the configuration file).
Make sure that /var/log/apache2/error_log
contains a line that tells you the php5_module is enabled — you should see PHP/5.3.15
(or similar).
[notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch configured -- resuming normal operations
Looking up Socket file’s name
When MySQL is up and running (with ./bin/mysqld_safe
) there should be debug lines printed out to the console that tell you where you can find the log files. Note the hostname in the file name — localhost
in my case — that may be different for your configuration.
The file that comes after Logging to
is important. That’s where MySQL logs its work.
130309 12:17:59 mysqld_safe Logging to '/Users/jacek/apps/mysql/data/localhost.err'.
130309 12:17:59 mysqld_safe Starting mysqld daemon with databases from /Users/jacek/apps/mysql/data
Open the localhost.err
file (again, yours might be named differently), i.e. tail -1 /Users/jacek/apps/mysql/data/localhost.err
to find out the socket file’s name — it should be the last line.
$ tail -1 /Users/jacek/apps/mysql/data/localhost.err
Version: '5.5.27' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
Note the socket:
part — that’s the socket file you should use in php.ini
.
There’s another way (some say an easier way) to determine the location of the socket’s file name by logging in to MySQL and running:
show variables like '%socket%';
Configuring PHP5 with MySQL support — /etc/php.ini
Speaking of php.ini…
In /etc
directory there’s /etc/php.ini.default file. Copy it to /etc/php.ini.
sudo cp /etc/php.ini.default /etc/php.ini
Open /etc/php.ini
and look for mysql.default_socket.
sudo vi /etc/php.ini
The default of mysql.default_socket
is /var/mysql/mysql.sock
. You should change it to the value you have noted earlier — it was /tmp/mysql.sock
in my case.
Replace the /etc/php.ini
file to reflect the socket file’s name:
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
Final verification
Restart Apache HTTP.
sudo apachectl restart
Check the logs if there are no error related to PHP5. No errors means you’re done and PHP5 with MySQL should work fine. Congrats!
если подключаешься через unix domain socket, посмотри, правильно ли указал путь до него.
но судя по «Перезапускаю mysql пишет: sh: 0: getcwd() failed: No such file or directory», у тебя намного бОльшие проблемы…
начни с того, рабочий ли у тебя вообще винчестер, или копыта уже откинул.
потом если правил конфиги мускула, я в нем не особый знаток, но если там есть путь до каталога с данными, посмотри, верен ли он. и всё такое прочее.
я ставлю на то, что фс сломалась и следующий ребут для сервака последний
This is for Mac OS X with the native installation of Apache HTTP and custom installation of MySQL.
The answer is based on @alec-gorge’s excellent response, but since I had to google some specific changes to have it configured in my configuration, mostly Mac OS X-specific, I thought I’d add it here for the sake of completeness.
Enable PHP5 support for Apache HTTP
Make sure the PHP5 support is enabled in /etc/apache2/httpd.conf
.
Edit the file with sudo vi /etc/apache2/httpd.conf
(enter the password when asked) and uncomment (remove ;
from the beginning of) the line to load the php5_module module.
LoadModule php5_module libexec/apache2/libphp5.so
Start Apache HTTP with sudo apachectl start
(or restart
if it’s already started and needs to be restarted to re-read the configuration file).
Make sure that /var/log/apache2/error_log
contains a line that tells you the php5_module is enabled — you should see PHP/5.3.15
(or similar).
[notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch configured -- resuming normal operations
Looking up Socket file’s name
When MySQL is up and running (with ./bin/mysqld_safe
) there should be debug lines printed out to the console that tell you where you can find the log files. Note the hostname in the file name — localhost
in my case — that may be different for your configuration.
The file that comes after Logging to
is important. That’s where MySQL logs its work.
130309 12:17:59 mysqld_safe Logging to '/Users/jacek/apps/mysql/data/localhost.err'.
130309 12:17:59 mysqld_safe Starting mysqld daemon with databases from /Users/jacek/apps/mysql/data
Open the localhost.err
file (again, yours might be named differently), i.e. tail -1 /Users/jacek/apps/mysql/data/localhost.err
to find out the socket file’s name — it should be the last line.
$ tail -1 /Users/jacek/apps/mysql/data/localhost.err
Version: '5.5.27' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
Note the socket:
part — that’s the socket file you should use in php.ini
.
There’s another way (some say an easier way) to determine the location of the socket’s file name by logging in to MySQL and running:
show variables like '%socket%';
Configuring PHP5 with MySQL support — /etc/php.ini
Speaking of php.ini…
In /etc
directory there’s /etc/php.ini.default file. Copy it to /etc/php.ini.
sudo cp /etc/php.ini.default /etc/php.ini
Open /etc/php.ini
and look for mysql.default_socket.
sudo vi /etc/php.ini
The default of mysql.default_socket
is /var/mysql/mysql.sock
. You should change it to the value you have noted earlier — it was /tmp/mysql.sock
in my case.
Replace the /etc/php.ini
file to reflect the socket file’s name:
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
Final verification
Restart Apache HTTP.
sudo apachectl restart
Check the logs if there are no error related to PHP5. No errors means you’re done and PHP5 with MySQL should work fine. Congrats!
Ошибка «No such file or directory» появляется, когда нужный файл отсутствует.
Давайте исключим самое банальное:
1. Файла нет на диске
user@pc1:~$ cat hello.cpp cat: hello.cpp: No such file or directory
Поскольку отсутствует файл hello.cpp , то выводится ошибка
2. Кириллица в названии
Проверьте, что в названии файла буква «с» не написана кириллицей. Например в расширении «.cpp».
3. Неправильный путь
Пример из Python
data_file= open ("../text.txt",'r')
«../» в общем случае говорит о том, что файл будет искаться на 1 директорию выше, чем файл с кодом.
Если файл лежит в директории с кодом, то следует писать:
data_file= open ("./text.txt",'r')
4. Неправильная битность
Вы можете увидеть ту же ошибку, если пытаетесь запустить например 64-битное приложение на 32-битной Windows
5. Более экзотические причины.
Причина ошибки может быть самой разной, в зависимости от приложения, которое вы используете.
Если это как раз тот случай, напишите о нем в комментариях, в будущем это очень поможет другим.
Нашли опечатку или ошибку? Выделите её и нажмите Ctrl+Enter
Помогла ли Вам эта статья?
Сайт на движке Bitrix может работать исправно и вдруг в самый неподходящий момент при заходе на сайт может возникнуть ошибка «Mysql connect error localhost 2002 No such file or directory 400».
Возможные причины:
- Закончилось свободное место на диске.
- Некорректные данные для подключения к базе данных.
- Проблема с базой данных.
Первым делом нужно зайти в панель управления хостингом и проверить, не закончилось ли место на диске (в разных системах может быть по-разному, к примеру — Инструменты — Свободное место). Если гипотеза подтвердилась, идем в менеджер файлов — www/названиеСайта/bitrix/backup — удаляем лишние бэкапы, либо пишем запрос в техподдержку хостинга, чтобы почистили место на диске, заодно можно будет в дальнейшем сделать так, чтобы на диске оставлять резерв, чтобы место внезапно не кончалось в будущем.
Возможно, на сайте не включен дебаг-режим и ошибки вы не увидите, чтобы включить дебаг-режим: менеджер файлов — www/названиеСайта/bitrix/php_interface — в файле dbconn.php в $DBDebug и $DBDebugToFile заменить с false на true.
Чтобы изменить настройки подключения к базе данных, в том же файле dbconn.php можно изменить значения в $DBLogin, $DBPassword, $DBName на нужные. Также настройки подключения к БД хранятся в файле www/названиеСайта/bitrix.settings.php (поля database, login, password соответственно).
Если повреждена база данных, зайти в резервные копии в панели управления хостингом и восстановить базу данных из резервной копии (на момент, когда база работала нормально).
2021.08.27
В новом обновлении файлы Битрикса конфликтуют со старыми версиями нашего решением.
Чтобы это исправить, мы доработали модуль Intec.Core.
Для восстановления работы сайта нужно обновить модуль Intec.Core через раздел админки Marketplace или вручную как описано ниже:
- Пройти по пути /bitrix/modules/intec.core/classes/
- Открыть файл Core.php
- Заменить его содержимое на код, представленный ниже
- Сохранить файл.
<?php
namespace intec;
require(__DIR__ . '/CoreBase.php');
use inteccoreCoreBase;
use inteccorediContainer;
use inteccorehelpersEncoding;
class Core extends CoreBase
{
}
spl_autoload_register(['intecCore', 'autoload'], true, true);
Core::$classes = require(__DIR__.'/classes.php');
Core::$container = new Container();
// global $DB;
$settingsDB = include($_SERVER["DOCUMENT_ROOT"]."/bitrix/.settings.php");
$settingsDB = $settingsDB["connections"]["value"]["default"];
$DBHostParts = explode(':', $settingsDB["host"]);
$DBHostAddress = $DBHostParts[0];
$DBHostPort = isset($DBHostParts[1]) ? $DBHostParts[1] : null;
(new corebaseApplication([
'id' => 'intec.core',
'basePath' => $_SERVER['DOCUMENT_ROOT'],
'charset' => Encoding::resolve(SITE_CHARSET),
'components' => [
'db' => [
'dsn' => 'mysql:host='.$DBHostAddress.';dbname='.$settingsDB["database"].(!empty($DBHostPort) ? ';port='.$DBHostPort : null),
'username' => $settingsDB["login"],
'password' => $settingsDB["password"],
'charset' => Encoding::resolve(SITE_CHARSET, Encoding::TYPE_DATABASE)
]
]
]));
unset($DBHostParts);
unset($DBHostAddress);
unset($DBHostPort);
Core::setAlias('@root/linked', dirname(dirname(dirname(dirname(__DIR__)))));
Core::setAlias('@bitrix', '@root'.BX_ROOT);
Core::setAlias('@upload', '@root/upload');
Core::setAlias('@modules', '@bitrix/modules');
Core::setAlias('@resources', '@bitrix/resources');
Core::setAlias('@templates', '@bitrix/templates');
Core::setAlias('@themes', '@bitrix/themes');
Core::setAlias('@intec/core/module', dirname(__DIR__));
Core::setAlias('@intec/core/libraries', '@intec/core/module/libraries');
Core::setAlias('@intec/core/resources', '@resources/'.Core::$app->id);
require(__DIR__.'/web.php');
Наши решения
yura5:
Панель управления — ISP manager
ну так к авторам и обращайтесь. кто лучше них ответит?
а вообще «No such file or directory» говорит о том, что php (предполагаю… кто знает чем вы там подключаетесь) не нашел сокет mysql’я
mysql сервер может работать по сети (по ip) или локально через unix socket
т.е. варианта два:
1) mysql сервер не запущен, файла сокета просто нет.
2) mysql работает, но в php.ini указан не тот путь к сокету.
смотрите my.cnf что там за путь указан в разделе [mysqld] в переменной socket
проверьте работает ли вообще mysql. найдите, создался ли сокет по указанному адресу.
если все ок, то смотрите php.ini в переменную mysql.default_socket или mysqli.default_socket или pdo_mysql.default_socket… кто знает что там у вас используется.
можно создать файл с любым именем с:
<?phpinfo();?>
и зайти посмотреть что там сейчас, какой сокет указан для mysql
после правки конфигов соответствющий сервер нужно перезапустить чтоб применились изменения.
This one can be a pesky error to sort out, but no fear – we’ve got your back!
You’re probably here frustrated so lets get straight to the point. As you’ve probably already guessed, there’s a file or directory that cannot be found.
The full error possible looks something like this:
Warning: mysqli_connect(): (HY000/2002): No such file or directory in <directory path> on line <number> Failed to connect to MySQL: No such file or directory
For most causes though, this error is a little bit on the cryptic side. When I fixed most of these errors it’s not usually related to the file or directory explicitly, but the host. I’m sure you’ve already checked a million times that the file/directory does exist and pulled out much hair over it.
How To Fix
Check the host name! Whether you’re running XAMMP, AMPPS or using shared hosting, dedicated servers etc.
The simplest fix, although possibly not the most elegant is to change your connection references from ‘localhost‘ to ‘127.0.0.1‘ – this will always work, no matter what your programing language or framework.
So in PHP your connection string would start:
$con=mysqli_connect("127.0.0.1",...
The Elegant Route
Shouldn’t PHP know about localhost? Yes, but you need to configure in in your global settings to make it understand this. If you have shared hosting, this may have already been taken care for you. If you had a nice installer for your local web server of choice bundled with things like PHP then it might have sorted this for you. This may be why your scratching your head wondering why it isn’t working now.
There’s so many languages, frameworks, server software and setups that it’s impossible to cover the configuration of all in this article but if you’ve got any special requests, drop them in the comments below and we’ll see what we can do!
Remember!
Just in case you haven’t done already, do actually check the file and directory exist. I know, I know, you’ve already done that but the article wouldn’t be completed without mentioning it! I’ve put it at the bottom so as not to distract from the likely fix to your problem above!
Есть сайт на Битриксе, у которого не удаётся подрубиться к базе по localhost:
[BitrixMainDBConnectionException]
Mysql connect error [localhost]: (2002) No such file or directory (400)
/home/bitrix/www/bitrix/modules/main/lib/db/mysqliconnection.php:85
#0: BitrixMainDBMysqliConnection->connectInternal()
/home/bitrix/www/bitrix/modules/main/lib/data/connection.php:53
#1: BitrixMainDataConnection->getResource()
/home/bitrix/www/bitrix/modules/main/lib/db/mysqlisqlhelper.php:21
#2: BitrixMainDBMysqliSqlHelper->forSql(string)
/home/bitrix/www/bitrix/modules/main/lib/config/option.php:206
#3: BitrixMainConfigOption::load(string)
/home/bitrix/www/bitrix/modules/main/lib/config/option.php:83
#4: BitrixMainConfigOption::getRealValue(string, string, boolean)
/home/bitrix/www/bitrix/modules/main/lib/config/option.php:32
#5: BitrixMainConfigOption::get(string, string, string)
/home/bitrix/www/bitrix/modules/main/lib/httprequest.php:420
#6: BitrixMainHttpRequest->prepareCookie(array)
/home/bitrix/www/bitrix/modules/main/lib/httprequest.php:77
#7: BitrixMainHttpRequest->__construct(object, array, array, array, array)
/home/bitrix/www/bitrix/modules/main/lib/httpapplication.php:42
#8: BitrixMainHttpApplication->initializeContext(array)
/home/bitrix/www/bitrix/modules/main/lib/application.php:133
#9: BitrixMainApplication->initializeExtendedKernel(array)
/home/bitrix/www/bitrix/modules/main/include.php:23
#10: require_once(string)
/home/bitrix/www/bitrix/modules/main/include/prolog_before.php:14
#11: require_once(string)
/home/bitrix/www/bitrix/modules/main/include/prolog.php:10
#12: require_once(string)
/home/bitrix/www/bitrix/header.php:1
#13: require(string)
/home/bitrix/www/index.php:1
----------
Подскажите в чём может быть проблема?!?
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
1 |
|
24.10.2022, 17:05. Показов 2440. Ответов 12
При заходе на любую страницу Битрикс выдаёт ошибку: Код [BitrixMainDBConnectionException] Mysql connect error [localhost]: (2002) No such file or directory (400) /home/bitrix/www/bitrix/modules/main/lib/db/mysqliconnection.php:82 #0: BitrixMainDBMysqliConnection->connectInternal() /home/bitrix/www/bitrix/modules/main/lib/data/connection.php:53 #1: BitrixMainDataConnection->getResource() /home/bitrix/www/bitrix/modules/main/lib/db/mysqlisqlhelper.php:21 #2: BitrixMainDBMysqliSqlHelper->forSql(string) /home/bitrix/www/bitrix/modules/main/lib/config/option.php:206 #3: BitrixMainConfigOption::load(string) /home/bitrix/www/bitrix/modules/main/lib/config/option.php:83 #4: BitrixMainConfigOption::getRealValue(string, string, boolean) /home/bitrix/www/bitrix/modules/main/lib/config/option.php:32 #5: BitrixMainConfigOption::get(string, string, string) /home/bitrix/www/bitrix/modules/main/lib/httprequest.php:394 #6: BitrixMainHttpRequest->prepareCookie(array) /home/bitrix/www/bitrix/modules/main/lib/httprequest.php:71 #7: BitrixMainHttpRequest->__construct(object, array, array, array, array) /home/bitrix/www/bitrix/modules/main/lib/httpapplication.php:49 #8: BitrixMainHttpApplication->initializeContext(array) /home/bitrix/www/bitrix/modules/main/lib/application.php:130 #9: BitrixMainApplication->initializeExtendedKernel(array) /home/bitrix/www/bitrix/modules/main/include.php:21 #10: require_once(string) /home/bitrix/www/bitrix/modules/main/include/prolog_before.php:14 #11: require_once(string) /home/bitrix/www/bitrix/modules/main/include/prolog.php:10 #12: require_once(string) /home/bitrix/www/bitrix/header.php:1 #13: require(string) /home/bitrix/www/index.php:1 ---------- Подскажите в чем может быть проблема? 0 |
1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
|
24.10.2022, 18:00 |
2 |
проверяйте работу Бд и наличие места на диске 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
24.10.2022, 18:19 [ТС] |
3 |
проверяйте работу Бд БД активна: Место на диске тоже имеется: 0 |
1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
|
25.10.2022, 07:56 |
4 |
Вы проверили активность СУБД. Я про БД 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
25.10.2022, 11:04 [ТС] |
5 |
Проверьте на месте ли сама БД. Если не ошибаюсь должна быть /var/lib/mysql/<bdname> БД на менсте
Подключиться mysql -u <username> -p <bdname> Подключился всё ok:
error.log Тут много чего, вот последние ошибки: Код 2022-10-25T07:41:08.525258Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:09.526303Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:09.526329Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:10.526915Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:10.526942Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:11.527232Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:11.527259Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:12.528236Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:12.528263Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:13.529015Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:13.529042Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:14.529653Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:14.529680Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:15.530320Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:15.530349Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:16.530632Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:16.530660Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:17.531048Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:17.531074Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:18.531370Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:18.531397Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:19.531679Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:19.531707Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:20.532540Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:20.532567Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:21.532806Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:21.532835Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:22.533331Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:22.533358Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:23.533580Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:23.533606Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:24.534329Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:24.534355Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:25.534479Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:25.534506Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:26.534895Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:26.534922Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:27.535687Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:27.535714Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:28.536944Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:28.536971Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:29.537518Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:29.537546Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:30.538352Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:30.538379Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:31.539029Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:31.539059Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:32.539425Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:32.539453Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:33.540455Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:33.540483Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:34.541047Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:34.541075Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:35.541558Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:35.541585Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:36.542091Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:36.542119Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:37.542517Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:37.542544Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:38.542893Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:38.542919Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:39.543140Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2022-10-25T07:41:39.543167Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2022-10-25T07:41:39.543176Z 0 [Note] InnoDB: Unable to open the first data file 2022-10-25T07:41:39.543192Z 0 [ERROR] InnoDB: Operating system error number 11 in a file operation. 2022-10-25T07:41:39.543207Z 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable' 2022-10-25T07:41:39.543215Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
<bdname>-error.log Отдельных логов для БД там нет
access.log Такого тоже нет
<bdname>-access.log И этого тоже не не нашёл 0 |
voral 1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
||||
25.10.2022, 14:47 |
6 |
|||
Больше всего «напрягает» InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. Я бы начал с перезагрузки mysql. при чем не restart а сначала stop — убедиться что все процессы завершились — и потом start На всякий случай (потом) попробовать можно
правда тут InnoDB…. -r — восстановление, можно сначала -a (анализировать) 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
25.10.2022, 17:09 [ТС] |
7 |
Я бы начал с перезагрузки mysql. при чем не restart а сначала stop — убедиться что все процессы завершились — и потом start Да пробовал уже. Причем именно так как Вы описали
можно сначала -a (анализировать) Выполнил анализ, под конец получил такие вот ошибки: Код Error : Table './enex_db/softpodkluch_dhl_cities' is marked as crashed and should be repaired Error : Table 'softpodkluch_dhl_cities' is marked as crashed and should be repaired Error : 1 client is using or hasn't closed the table properly status : Table is already up to date enex_db.softpodkluch_dhl_config Error : Table './enex_db/softpodkluch_dhl_config' is marked as crashed and should be repaired Error : Table 'softpodkluch_dhl_config' is marked as crashed and should be repaired Error : 1 client is using or hasn't closed the table properly status : Table is already up to date enex_db.softpodkluch_dhl_countries Error : Table './enex_db/softpodkluch_dhl_countries' is marked as crashed and should be repaired Error : Table 'softpodkluch_dhl_countries' is marked as crashed and should be repaired Error : 1 client is using or hasn't closed the table properly status : Table is already up to date enex_db.softpodkluch_dhl_data Error : Table './enex_db/softpodkluch_dhl_data' is marked as crashed and should be repaired Error : Table 'softpodkluch_dhl_data' is marked as crashed and should be repaired Error : 1 client is using or hasn't closed the table properly status : Table is already up to date enex_db.softpodkluch_dhl_debug OK enex_db.softpodkluch_dhl_regions Error : Table './enex_db/softpodkluch_dhl_regions' is marked as crashed and should be repaired Error : Table 'softpodkluch_dhl_regions' is marked as crashed and should be repaired Error : 1 client is using or hasn't closed the table properly status : Table is already up to date enex_db.softpodkluch_dhl_services Table is already up to date enex_db.sprint_migration_archive OK enex_db.sprint_migration_versions OK enex_db.sprint_storage_default OK Добавлено через 17 минут
попробовать можно Тоже попробовал. Под конец несколько таблиц восстановились: Код enex_db.shipment_date note : The storage engine for the table doesn't support repair enex_db.softpodkluch_dhl_cache OK enex_db.softpodkluch_dhl_cities OK enex_db.softpodkluch_dhl_config OK enex_db.softpodkluch_dhl_countries OK enex_db.softpodkluch_dhl_data OK enex_db.softpodkluch_dhl_debug OK enex_db.softpodkluch_dhl_regions OK enex_db.softpodkluch_dhl_services OK enex_db.sprint_migration_archive note : The storage engine for the table doesn't support repair enex_db.sprint_migration_versions у остальных было сообщение типа этого: Код note : The storage engine for the table doesn't support repair enex_db.sprint_migration_versions На решении проблемы это никак не сказалось 0 |
1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
|
25.10.2022, 17:40 |
8 |
хм…. тут, возможно, лучше в раздел по MySQL (именно с показаниями лога). Возможно есть смысл в ТП хостинга обратиться. Но это все следствие. А вот причина. То что БД крашится не очень хорошо… может диск или память так сказываются. (были на одном проектом «не понятные» проблемы) выяснилось: что то было с железом. Возможно, есть смысл из бекапа развернуться. (если он есть не битый — для начала куда то тестово) Смотрю таблицы не штатные. В админку не пускает? Добавлено через 3 минуты Добавлено через 1 минуту 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
25.10.2022, 17:57 [ТС] |
9 |
Возможно есть смысл в ТП хостинга обратиться Это не хост, это виртуалка на обычном компе
может диск или память так сказываются Возможно. Просто вот в чем суть: была виртуальная машина, которая слетела. Всё что от неё осталось это виртуальный жёсткий диск. Я создал новую виртуалку, к которой подключил данный жёсткий диск и вот на нём получаю такую ошибку.
В админку не пускает? Нет вообще никуда не пускает
есть смысл из бекапа развернуться Наверное да. Сегодня накатил свежую базу данных из бекапа. Не помогло 0 |
1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
|
25.10.2022, 18:02 |
10 |
Хм…. «свежую бд»? а как разворачивали? Кроме того как можно проверить такую гипотезу: у виртуалок бывает режим когда дисковая память динамическая. Т.е. указали, например, 40Гб… а оно меньше и добавляется только при необходимости…. я не помню можно ли «переключить» в фиксированную — но проверить это. Так же если восстанавливали поверх старой — попробовать развернуть в другую, в новую БД. Т.е., тут если уже и эта БД будет не живая — значит что то не то с виртуалкой. 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
25.10.2022, 18:22 [ТС] |
11 |
а как разворачивали? Ну там сложная тема, но зато проверенная много раз её делал. Если которотко то с сервера скачивается архив с бэкапом, распаковывается, все файлы прогоняются через innobackupex, затем у них меняется владелец на mysql, после чего они перемещаются в папку /var/lib/mysql/….. PROFIT
я не помню можно ли «переключить» в фиксированную — но проверить это Да не дело вряд-ли в этом, так как сегодня чтобы обновить БД, докинул несколько гигобайт на рут: 0 |
voral 1729 / 1075 / 219 Регистрация: 16.03.2008 Сообщений: 5,067 Записей в блоге: 2 |
||||
25.10.2022, 19:49 |
12 |
|||
хм… с копированием…. несколько странно. там ведь еще и в системные таблицы мускула записи идут… не пробовал так ни когда… Я либо (для битрикс проектов — штатным бекап/разбекап) либо (если у меня sql дамп) то
Добавлено через 1 минуту
Да не дело вряд-ли в этом, так как сегодня чтобы обновить БД, докинул несколько гигобайт на рут Смотря как эта штука работает. Драйвер то может там хитрый драйвер — который всегда выдает системе фиксированный размер хотя реальный другой. 1 |
975 / 498 / 101 Регистрация: 20.02.2016 Сообщений: 2,845 |
|
28.10.2022, 14:13 [ТС] |
13 |
В итоге решил проблему. База данных не открывалась на localhost, добавил в .settings.php этот порт: 127.0.0.1:3306 и всё заработало 0 |
I believe the issue here is that localhost
is not your database host. If that PHP script is running in the «www» docker container, localhost
most likely does not have a listening MySQL server. IIRC, the «file not found» error from mysqli is due to not finding the MySQL socket on localhost
. I also do not see that you are exposing any ports for the «db» image, so I am not sure how «www» is supposed to connect to a database running inside it.
You would want to find what the address to the «db» docker container is, and what port it is listening on, then reference that in your mysqli_connect()
function. An easier method, if you have a recent version of docker, would be to add your containers to the same Docker network and reference them by name.
EDIT: Docker Networking
You should read up on the networking feature in the official documentation as it is very useful. You can probably use the following docker-compose.yml (not tested):
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
- MYSQL_DATABASE=mgsv
- MYSQL_USER=mgsv_user
- MYSQL_PASSWORD=mgsvpass
- MYSQL_ROOT_PASSWORD=mysql123
volumes:
- ./mysql:/docker-entrypoint-initdb.d
networks:
- web-db-net
www:
build: ./mGSV
restart: always
ports:
- 8080:80
networks:
- web-db-net
networks:
web-db-net:
Then change your connect line to refer to the db container by name (you would also need to specify port if not using the MySQL default, 3306):
$con = mysqli_connect("db","mgsv_user","mgsvpass","mgsv");
EDIT2: fixed docker-compose.yml so that networks actually works