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.

AGIdil
gefragt vor 6 Monaten212 Aufrufe
5 Antworten
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
AGIdil
beantwortet vor 6 Monaten
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
EXPERTE
beantwortet vor 6 Monaten
0

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

profile picture
EXPERTE
beantwortet vor 6 Monaten
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         
  
AGIdil
beantwortet vor 6 Monaten
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.

AGIdil
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen