ERROR 2002 (HY000): Can't connect to local MySQL server
Posted: Wed Sep 12, 2018 9:53 am
Greetings,
I'm trying to restore nagios using the /usr/local/nagiosxi/scripts/restore_xi.sh script from a back up that i have created using backup_xi.sh
i'm encountering the following error:
[root@NagiosServer scripts]# ./restore_xi.sh /www/backups/nagiosxi/system/1536684731.tar.gz
WARNING: you are trying to restore a OS 7 backup on a OS 6 system
Compiled plugins and other binaries as well as httpd configurations
will NOT be restored.
Are you sure you want to continue? [y/N] y
TS=1536761815
Extracting backup to /www/backups/nagiosxi/1536761815-restore...
In /www/backups/nagiosxi/1536761815-restore/1536684731...
Backup files look okay. Preparing to restore...
Shutting down services...
Stopping nagios (via systemctl): [ OK ]
Stopping ndo2db (via systemctl): [ OK ]
NPCD Stopped.
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring Nagvis backups...
Restoring MySQL databases...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Error restoring MySQL database 'nagios' - check the password in this script!
You have new mail in /var/mail/root
Everything seems to be going good until when it starts to restore the MYSQL database.
I've checked and the database is running fine
[root@NagiosServer scripts]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-09-07 14:11:23 EDT; 4 days ago
Main PID: 27570 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─27570 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─28021 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid ...
Sep 07 14:11:21 ma209dlvnag001 systemd[1]: Starting MariaDB database server...
Sep 07 14:11:21 ma209dlvnag001 mariadb-prepare-db-dir[27539]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Sep 07 14:11:21 ma209dlvnag001 mariadb-prepare-db-dir[27539]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Sep 07 14:11:21 ma209dlvnag001 mysqld_safe[27570]: 180907 14:11:21 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Sep 07 14:11:21 ma209dlvnag001 mysqld_safe[27570]: 180907 14:11:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Sep 07 14:11:23 ma209dlvnag001 systemd[1]: Started MariaDB database server.
You have new mail in /var/mail/root
Can you please help here.
Thanks.
I'm trying to restore nagios using the /usr/local/nagiosxi/scripts/restore_xi.sh script from a back up that i have created using backup_xi.sh
i'm encountering the following error:
[root@NagiosServer scripts]# ./restore_xi.sh /www/backups/nagiosxi/system/1536684731.tar.gz
WARNING: you are trying to restore a OS 7 backup on a OS 6 system
Compiled plugins and other binaries as well as httpd configurations
will NOT be restored.
Are you sure you want to continue? [y/N] y
TS=1536761815
Extracting backup to /www/backups/nagiosxi/1536761815-restore...
In /www/backups/nagiosxi/1536761815-restore/1536684731...
Backup files look okay. Preparing to restore...
Shutting down services...
Stopping nagios (via systemctl): [ OK ]
Stopping ndo2db (via systemctl): [ OK ]
NPCD Stopped.
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring Nagvis backups...
Restoring MySQL databases...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Error restoring MySQL database 'nagios' - check the password in this script!
You have new mail in /var/mail/root
Everything seems to be going good until when it starts to restore the MYSQL database.
I've checked and the database is running fine
[root@NagiosServer scripts]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-09-07 14:11:23 EDT; 4 days ago
Main PID: 27570 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─27570 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─28021 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid ...
Sep 07 14:11:21 ma209dlvnag001 systemd[1]: Starting MariaDB database server...
Sep 07 14:11:21 ma209dlvnag001 mariadb-prepare-db-dir[27539]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Sep 07 14:11:21 ma209dlvnag001 mariadb-prepare-db-dir[27539]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Sep 07 14:11:21 ma209dlvnag001 mysqld_safe[27570]: 180907 14:11:21 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Sep 07 14:11:21 ma209dlvnag001 mysqld_safe[27570]: 180907 14:11:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Sep 07 14:11:23 ma209dlvnag001 systemd[1]: Started MariaDB database server.
You have new mail in /var/mail/root
Can you please help here.
Thanks.