Can't access MySQL in a new instance created from a snapshot

0

SSH was corrupted in my Lightsail instance. I have created a manual snapshot from my instance. Using this snapshot I have created another instance. I was able to reach this instance using SSH. This time I was unable to reach MySQL via console of this newly created instance. Trying to start/restart the service didn't work at all. The error output is as follows:

root@ip-172-26-7-211:/home/bitnami# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local server through socket '/opt/bitnami/mariadb/tmp
/mysql.sock' (2)

In fact there is no mysql.sock file at this location.

preguntada hace un año321 visualizaciones
5 Respuestas
1

I have added

innodb_force_recovery = 1

in

 /opt/bitnami/mariadb/conf/my.cnf

under [mysqld] and executed the following:

root@ip:/opt/bitnami# mysqld --skip-grant-tables --user=mysql --skip-external-locking --port=3306 --sock=/opt/bitnami/mariadb/tmp/mysql.sock

Then I was able to connect to MySQL console issuing

mysql -u root -p
respondido hace un año
0

Try connecting via the IP instead of the socket

mysql -h 127.0.0.1 -P 3306 -u root -p <database>

Also see if its running telnet 127.0.0.1 3306

profile picture
EXPERTO
respondido hace un año
0

What results are returned with netstat -an |grep 3306 ? Is NC installed? netcat to 127.0.0.1 3306

profile picture
EXPERTO
respondido hace un año
0
root@ip:/opt/bitnami# ./ctlscript.sh status
apache already running
mariadb already running
php-fpm not running
root@ip:/opt/bitnami# netstat -an | grep 3306
root@ip:/opt/bitnami# netcat to 127.0.0.1 
3306
netcat: port number invalid: 127.0.0.1
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name  
  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1443/sshd: /usr/sb
i 
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      696/sendmail: MTA:
  
tcp        0      0 127.0.0.1:587           0.0.0.0:*               LISTEN      696/sendmail: MTA:
  
tcp6       0      0 :::22                   :::*                    LISTEN      1443/sshd: /usr/sb
i 
tcp6       0      0 :::443                  :::*                    LISTEN      839/httpd         
  
tcp6       0      0 :::80                   :::*                    LISTEN      839/httpd         
  
respondido hace un año
0
root@ip:/opt/bitnami# ./ctlscript.sh status
apache already running
mariadb not running
php-fpm already running
root@ip:/opt/bitnami# ./ctlscript.sh start mariadb
Started mariadb
root@ip:/opt/bitnami# mysql -h 127.0.0.1 -P 3306 -u root -p my_database
Enter password: 
ERROR 2002 (HY000): Can't connect to server on '127.0.0.1' (115)

Telnet is disabled.

respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas