Error: Can't connect to local MySQL server through socket


#1

Hi
I am a new fedora user and i am installing ROR on my machine. but when i
try to enter the following command, it shows the following errors.
can any one please tell me how can i solve this problem.

[smehsan@localhost proone]$ rake db:create
#<Mysql2::Error: Can’t connect to local MySQL server through socket
‘/var/run/mysqld/mysqld.sock’ (13 “Permission denied”)>
Couldn’t create database for {“adapter”=>“mysql2”, “encoding”=>“utf8”,
“pool”=>5, “username”=>“root”, “password”=>nil,
“socket”=>"/var/run/mysqld/mysqld.sock",
“database”=>“proone_development”}, {:charset=>“utf8”,
:collation=>“utf8_unicode_ci”}
(If you set the charset manually, make sure you have a matching
collation)
#<Mysql2::Error: Can’t connect to local MySQL server through socket
‘/var/run/mysqld/mysqld.sock’ (13 “Permission denied”)>
Couldn’t create database for {“adapter”=>“mysql2”, “encoding”=>“utf8”,
“pool”=>5, “username”=>“root”, “password”=>nil,
“socket”=>"/var/run/mysqld/mysqld.sock", “database”=>“proone_test”},
{:charset=>“utf8”, :collation=>“utf8_unicode_ci”}
(If you set the charset manually, make sure you have a matching
collation)
[smehsan@localhost proone]$


#2

On 15 May 2016 at 13:15, Sm Ehsan removed_email_address@domain.invalid wrote:

“pool”=>5, “username”=>“root”, “password”=>nil,
That says you are trying to connect as user root with no password. Is
that what you intended? If not have you got the correct user and pwd
in config/database.yml?

Colin


#3

Thank You @colin

But how can i change that and where can i find config/database.yml file?


#4

Colin L. wrote in post #1183468:

On 15 May 2016 at 13:15, Sm Ehsan removed_email_address@domain.invalid wrote:

“pool”=>5, “username”=>“root”, “password”=>nil,
That says you are trying to connect as user root with no password. Is
that what you intended? If not have you got the correct user and pwd
in config/database.yml?

Colin

“Here is my database.yml file”

https://gist.github.com/ehsanatwork/60d8c258606ab68494165dc099a2c23d


#5

On 15 May 2016 at 13:30, Sm Ehsan removed_email_address@domain.invalid wrote:

Thank You @colin

But how can i change that and where can i find config/database.yml file?

Please remember to quote the previous message when replying, otherwise
no-one knows what you are referring to. This is a mailing list not a
forum, though you may be accessing it via a forum-like interface.
Thanks.

It is in the config folder in your rails application.
Since you did not know that I suggest that you work right through a
good tutorial such as railstutorial.org (which is free to use online).
That will show you the basics of rails.

Colin


#6

Colin L. wrote in post #1183472:

On 15 May 2016 at 13:35, Sm Ehsan removed_email_address@domain.invalid wrote:

“Here is my database.yml file”

https://gist.github.com/ehsanatwork/60d8c258606ab68494165dc099a2c23d

As I thought, you have specified root and no password as the default,
and used that for development. I suggest working through the
tutorial, it will save you a lot of time.

Colin

Thank you,
Did you check the gist.
I have installed ruby, rails, mysql database.
but i am toomuch confused why this errors happen?
I hope you will help me.
Thank You


#7

which tutorial?


#8

On 15 May 2016 at 13:41, Sm Ehsan removed_email_address@domain.invalid wrote:

Colin

Thank you,
Did you check the gist.

Yes, in there you have specified user root with no password, which I
presume is not what you intended.
To fix it you must use a valid user/pwd for your mysql server.

Colin


#9

On 15 May 2016 at 13:46, Sm Ehsan removed_email_address@domain.invalid wrote:

which tutorial?

The one in my second (I think) post.

Colin


#10

On 15 May 2016 at 13:35, Sm Ehsan removed_email_address@domain.invalid wrote:

“Here is my database.yml file”

https://gist.github.com/ehsanatwork/60d8c258606ab68494165dc099a2c23d

As I thought, you have specified root and no password as the default,
and used that for development. I suggest working through the
tutorial, it will save you a lot of time.

Colin