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.
[root@ip-172-31-46-255 ~]# 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