Bonjour,

J'ai voulus faire un site avec mysql pour la première fois ^^ problème c'est que ça ma fait une erreur donc j'ai créer ma migration avec rails g migration .... (les info qui faut ^^) puis après j'ai fait rails db:migrate et la boom explosion d'erreur ^^

rails aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")
/home/maxime/.gem/ruby/2.3.0/gems/mysql2-0.4.5/lib/mysql2/client.rb:89:in `connect'
/home/maxime/.gem/ruby/2.3.0/gems/mysql2-0.4.5/lib/mysql2/client.rb:89:in `initialize'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in `new_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in `checkout_new_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in `try_to_checkout_new_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `acquire_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in `checkout'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in `retrieve_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:91:in `connection'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1099:in `initialize'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `new'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/home/maxime/Sites/My Project/Learn/bin/rails:9:in `require'
/home/maxime/Sites/My Project/Learn/bin/rails:9:in `<top (required)>'
/home/maxime/Sites/My Project/Learn/bin/spring:14:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Puis après je me suis dit on vas voir se que ça fait si je tape mysql dans mon terminal

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")

Donc je sais pas comment je doit faire pour faire ma migrate sans bug ^^

PS : je suis sur antergos j'ai installer le paquet mariadb (qui installe mysql en dépendance) et je suis actuellement les tuto youtube de rails de grafikart ;)

Merci pour votre aide ;)

6 réponses


regarde si tu as ce fichier sur ta machine : /run/mysqld/mysqld.sock
tu es sur que mysql est lancé ?

Merci il n'était pas lancer :/ mais j'ai encore un problème il me dit qu'il ne connait pas ma base de donnée (je penser que rails le fesait tous seul) comment je doit faire pour créer la base de donnée qu'il lui manque ?
Voici l'erreur au cas où je me suis tromper

rails aborted! ActiveRecord::NoDatabaseError: Unknown database 
'Learn_development' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:29:in 
`rescue in mysql2_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:12:in 
`mysql2_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in 
`new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in 
`checkout_new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in 
`try_to_checkout_new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in 
`acquire_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in 
`checkout' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in 
`connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in 
`retrieve_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:128:in 
`retrieve_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:91:in 
`connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1099:in 
`initialize' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in 
`new' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in 
`up' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in 
`migrate' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in 
`migrate' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in 
`block (2 levels) in <top (required)>' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in 
`block in run_rake_task' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in 
`run_rake_task' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in 
`run_command!' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in 
`<top (required)>' /home/maxime/Sites/My Project/Learn/bin/rails:9:in 
`require' /home/maxime/Sites/My Project/Learn/bin/rails:9:in `<top 
(required)>' /home/maxime/Sites/My Project/Learn/bin/spring:14:in `<top 
(required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' 
Mysql2::Error: Unknown database 'Learn_development' 
/home/maxime/.gem/ruby/2.3.0/gems/mysql2-0.4.5/lib/mysql2/client.rb:89:in 
`connect' 
/home/maxime/.gem/ruby/2.3.0/gems/mysql2-0.4.5/lib/mysql2/client.rb:89:in 
`initialize' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in 
`new' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in 
`mysql2_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:721:in 
`new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:765:in 
`checkout_new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:744:in 
`try_to_checkout_new_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in 
`acquire_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:501:in 
`checkout' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in 
`connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:875:in 
`retrieve_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:128:in 
`retrieve_connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_handling.rb:91:in 
`connection' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1099:in 
`initialize' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in 
`new' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in 
`up' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in 
`migrate' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in 
`migrate' 
/home/maxime/.gem/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in 
`block (2 levels) in <top (required)>' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in 
`block in run_rake_task' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in 
`run_rake_task' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in 
`run_command!' 
/home/maxime/.gem/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in 
`<top (required)>' /home/maxime/Sites/My Project/Learn/bin/rails:9:in 
`require' /home/maxime/Sites/My Project/Learn/bin/rails:9:in `<top 
(required)>' /home/maxime/Sites/My Project/Learn/bin/spring:14:in `<top 
(required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => 
db:migrate (See full trace by running task with --trace) 
[maxime@Maxime-Developpement Learn]$

tu as fait un

rake db:create 

Vérifie si la base de données que tu as stipulé dans ton fichier database.yml existe belle est bien sur ton mysql (databasename, username et password).

@TheYoungGeek43 tu as resolu ton probleme? si oui c'etait quoi?

@Raphael, il a dit que son serveur n'était pas lancé (2nde réponse)