gpt4 book ai didi

mysql - ERRoR+Mysqld(无法通过套接字 '/var/run/mysqld/mysqld.sock' (2) 连接到本地 MySQL 服务器(Mysql2::Error)

转载 作者:行者123 更新时间:2023-11-29 19:04:57 24 4
gpt4 key购买 nike

ruby 2.2.3p173(2015-08-18 修订版 51636)[x86_64-linux]
Rails 5.0.0.1
服务器版本:5.7.13-0ubuntu0.16.04.2(Ubuntu)

数据库.yml

default: &default  
adapter: mysql2
encoding: utf8
pool: 5
username: ****
password: ****
socket: /var/run/mysqld/mysqld.sock

当我打开带有实体的页面时,它运行良好,但是当我尝试添加新记录时,出现错误:
Puma caught this error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Mysql2::Error)<br/>
/home/ruby/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in connect<br/>
/home/ruby/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4/lib/mysql2/client.rb:87:in initialize

在我输入rails server命令后,它会再次工作,直到我尝试添加新记录。我该如何修复这个错误?

最佳答案

这解决了它:

ps -A|grep mysql

sudo pkill mysql

ps -A|grep mysqld

sudo pkill mysqld

sudo service mysql restart

关于mysql - ERRoR+Mysqld(无法通过套接字 '/var/run/mysqld/mysqld.sock' (2) 连接到本地 MySQL 服务器(Mysql2::Error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43580132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com