C
C
chelkaz2017-02-09 17:04:40
linux
chelkaz, 2017-02-09 17:04:40

How to return data from MySQL?

I have been adding data to MySQL for about a month. Everything was fine, but today the server crashed and I rebooted it, after that it starts up but I can't connect to the database! How can I restore all data?
System:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.1 LTS
Release:	16.04
Codename:	xenial

mysql  Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using  EditLine wrapper

On startup: vagrant reload --provision
==> homestead-7: ERROR
==> homestead-7:  2002 (HY000)
==> homestead-7: : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Thu 2017-02-09 13:57:45 UTC; 10s ago
  Process: 9762 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
  Process: 9759 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 9762 (code=exited, status=2);         : 9763 (mysql-systemd-s)
    Tasks: 2
   Memory: 376.0K
      CPU: 255ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─9763 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─9801 sleep 1

Feb 09 13:57:45 homestead systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Feb 09 13:57:45 homestead systemd[1]: Stopped MySQL Community Server.
Feb 09 13:57:45 homestead systemd[1]: Starting MySQL Community Server...
Feb 09 13:57:45 homestead systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

This is how I understood the configuration file.
/etc/mysql$ sudo nano my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chelkaz, 2017-02-09
@chelkaz

Here's what I did and it worked after spending a few hours reading the documentation.

sudo -i
cd /var/lib/mysql/

Next, we look at what is in the directory:
sudo -i
ls -a
And delete:
sudo rm /var/lib/mysql/ib_logfile0
sudo rm /var/lib/mysql/ib_logfile1

At the end, we reboot vagrant
It was possible to restore everything without loss.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question