Looking at config/database.yml
development:
<<: *default
database: my_rails_app_development
This needs to be changed to
development:
adapter: mysql2
encoding: utf8
database: c9
username: <%=ENV['C9_USER']%>
host: <%=ENV['IP']%>
This gets your c9 username, and hostname (in this case 0.0.0.0) for you and inserts the values so you don't need to go figuring them out yourself. Now, when you restart the server, you get:
Can't connect to MySQL server on '0.0.0.0' (111)
Stop the server. Run: mysql-ctl start
And now restart the server (rails s -b $IP -p $PORT
)
If this still doesn't work, try: sudo service mysqld start
or sudo service mysql start
Credit to:
Cloud 9 IDE can't connect to database
Mysql can't connect to local server through socket on Amazon EC2
https://docs.c9.io/docs/running-a-rails-app