1

I get this error when I run rake db:create

root@guidir-smaill-group-1-po7p:/home/acc/site/site# RAILS_ENV=production rake db:create
#<Mysql2::Error: Lost connection to MySQL server at 'reading initial communication packet', system error: 0>
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>"pass", "host"=>"173.144.230.182", "database"=>"dbname"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)

The error seems fairly common and I've read a bunch of posts here on SO on how that fixed it. But they all include removing and re installing MySQL with a command like these

export ARCHFLAGS="-arch i386 -arch x86_64" gem install mysql -- --with-mysql-dir=/usr/local \ --with-mysql-config=/usr/local/bin/mysql_config

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Problem is that im using an SQL instance on google cloud and I dont want to uninstall the mysql setup they have there. How can I get the same result without re installing mysql so I can run rake db:create successfully?

Community
  • 1
  • 1
Rob
  • 1,835
  • 2
  • 25
  • 53
  • Have you whitelisted the IP of the machine you are connecting from? Are you able to connect to the instance from the same machine using the 'mysql' client? – Vadim Apr 28 '16 at 14:05
  • Yes it is whitelisted and I can connect to the mysql from the machine I'm on. – Rob Apr 28 '16 at 22:55
  • Hmm, interesting. I would suggest trying to reinstall the mysql gem per the instructions you have found in other posts. It should have no effect on your Cloud SQL instance, it will only reinstall the mysql client on your client machine. – Vadim Apr 29 '16 at 14:45
  • Were you able to resolve this following Vadim's suggestion? – Adam May 13 '16 at 17:10
  • @Adam no, I cant remember how I solved this either otherwise I would add it as an answer. – Rob May 14 '16 at 07:38

0 Answers0