mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
开始能登陆,后来就断开了
We're sorry, but something went wrong. If you are the application owner check the logs for more information.
重新启动service nginx restart后有时可以进入网址,但?http://39.98.75.113/addresses/new:有2种情况:
- 正常链接。这时我打开的是chrome或者safari。
- 同时打开chrome, safari用不同的账号登陆网址。
- 成功同步更新
- 报告❌。
??猜测是和内存有关,512的服务器内存太小了。
通过命令/etc/init.d/mysql status查看mysql的状态:
/etc/init.d/mysql status
或者:
service mysql status
正常情况:
<E2><97><8F> mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-11-10 18:33:42 CST; 52min ago Process: 803 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS) Process: 691 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 802 (mysqld) CGroup: /system.slice/mysql.service <E2><94><94><E2><94><80>802 /usr/sbin/mysqld Nov 10 18:33:39 iZ8vbcqz91cgdxkf2tcrsvZ systemd[1]: Starting MySQL Community Server... Nov 10 18:33:42 iZ8vbcqz91cgdxkf2tcrsvZ systemd[1]: Started MySQL Community Server.
失败情况: 显示正激活activing, 有failure.
<E2><97><8F> mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: activing since Sat 2018-11-10 18:33:42 CST; 52min ago Process: 803 ExecStartPost=/usr/share/mysql/mysql-systemd-start post
(code=exited, status=failure) Process: 691 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 802 (mysqld) CGroup: /system.slice/mysql.service <E2><94><94><E2><94><80>802 /usr/sbin/mysqld Nov 10 18:33:39 iZ8vbcqz91cgdxkf2tcrsvZ systemd[1]: Starting MySQL Community Server... Nov 10 18:33:42 iZ8vbcqz91cgdxkf2tcrsvZ systemd[1]: Started MySQL Community Server.
其他问题:
在远端进 rails console后, 有时候能链接上mysql, 有时候就显示Mysql2::Error::ConnectionError
这是因为mysql没有正常开启。
用deploy身份: cd ~/.your_project/current 执行 bundle exec rails c -e production
服务器端输入:mysql -u root -p
Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
最后重启动服务器,一切暂时ok.