[RAILS] Error when deploying EC2

error contents

Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I got an error like this when the deployment was completed in just one step ...


Probably because MariaDB on EC2 wasn't running. I was able to start it by the following method, but I did not directly issue the command to start it, so it may be a special case.

So, people who do not work even if they receive the start command Please try.


For the time being, let's check with the following command to confirm that MySQL is installed

mysql -v

If it is installed, use the following command In my case, I set up MariaDB Please enter the password when you made the setting.

mysql -u root -p

If you enter the password and it looks like this, it is successful.

[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

Next, check if there is a table list with the following command. When the table appears, it's done correctly.

MariaDB [(none)]> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| petter_production  |
4 rows in set (0.00 sec)

When the table appears, next, in my case, to better_production (table for my app) Check if there is a table list.

mysql -u root -D petter_production -p

MariaDB [petter_production]> show tables;
| Tables_in_petter_production |
| active_storage_attachments  |
| active_storage_blobs        |
| ar_internal_metadata        |
| comments                    |
| likes                       |
| pets                        |
| plans                       |
| relationships               |
| schema_migrations           |
| tweet_tag_relations         |
| tweet_tags                  |
| tweets                      |
| users                       |
13 rows in set (0.00 sec)

After checking so far, the error has been resolved. If the table list does not appear in the series of confirmations, the settings are not correct, so please look for other commands.

Recommended Posts

Error when deploying EC2
Error when deploying EC2 on CircleCI
Error when using SnapKit
When deploying to Heroku, OpenApp causes an error
Error when bundle install
error code 400 appears when deploying with release: perform
Possibility when deploying to EC2 but nothing is displayed in the error log
Error when playing with java
Error when using rails capybara
SpringBoot + Mybatis error when booting
Error when introducing SNS authentication
Error when npm install on Windows 7
DB error on deploying with Heroku
About error when implementing spring validation
[Unauthorized Operation] A memorandum because an error occurred when creating an EC2 instance.
(EC site) Validation when entering order information
SCSS doesn't work when deploying Rails6 AWS
Error in implementation when implementing Spring validation
Error when starting eclipse after upgrading JDK
A reminder when an aapt.exe error occurs
Javaw.exe error when starting Spring Boot (STS)