如果有人能帮我,我将不胜感激。我是后端新手,只是一名谦虚的设计师/前端人员。
好的 - 从头开始...:我有一台 Ubuntu 18.04.1 LTS Ubuntu 桌面,并且已经构建了几个月的本地 WordPress。我一直注意到我的盒子上空间不足,意识到这是 Flatpak [诅咒你 Flatpak!!!] 每天都在毫无理由地增加 GB 的空间。所以我咬紧牙关,把它删掉了。
当然,它毁了我的 WP 网站。经过几个小时的折磨,我终于重新安装了 Apache2 和 MySql。我记得在此过程中更改了一两个密码,所以我认为这可能是问题的一部分……无论如何,我确实回到了我的网站,并立即使用插件 [updraftplus] 将其备份到远程服务器。[所以最坏的情况是我会迁移到实时服务器,但更希望让它再次工作。]
但今天,我重新启动并检查了我的本地站点,发现 WP 站点/登录页面上都显示“建立数据库连接时出错”。所以我检查了 apache2 - 可以正常工作。Mysql 不行。
当我运行“service mysql status”时,我得到了以下信息:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-02-02 12:19:06 EST; 48min ago
Process: 3317 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Process: 3308 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Feb 02 12:19:06 kjj-desktop systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Feb 02 12:19:06 kjj-desktop systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Feb 02 12:19:06 kjj-desktop systemd[1]: Stopped MySQL Community Server.
Feb 02 12:19:06 kjj-desktop systemd[1]: mysql.service: Start request repeated too quickly.
Feb 02 12:19:06 kjj-desktop systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 02 12:19:06 kjj-desktop systemd[1]: Failed to start MySQL Community Server.
我找不到任何日志文件夹/文件 [该死的 Stacer!它杀死了 apache2 日志,我也怀疑是这个!] 此外,当我通过此 cmd“mysqladmin -u root -p status”检查 Mysql 的状态时,我得到了以下信息:
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!
这是来自系统日志的信息:
Feb 2 20:27:37 kjj-desktop systemd[1]: Starting MySQL Community Server...
Feb 2 20:27:37 kjj-desktop kernel: [10290.580203] audit: type=1400 audit(1549157257.767:141): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=15427 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Feb 2 20:27:37 kjj-desktop kernel: [10290.608820] audit: type=1400 audit(1549157257.795:142): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=15429 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=124 ouid=0
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.975231Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.976433Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.25-0ubuntu0.18.04.2) starting as process 15431 ...
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.978696Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: No such file or directory
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.978727Z 0 [ERROR] Aborting
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.978771Z 0 [Note] Binlog end
Feb 2 20:27:37 kjj-desktop mysqld[15429]: Initialization of mysqld failed: 0
Feb 2 20:27:37 kjj-desktop mysqld[15429]: 2019-02-03T01:27:37.978842Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Feb 2 20:27:37 kjj-desktop systemd[1]: mysql.service: Control process exited, code=exited status=1
Feb 2 20:27:37 kjj-desktop systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 2 20:27:37 kjj-desktop systemd[1]: Failed to start MySQL Community Server.
Feb 2 20:27:38 kjj-desktop systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Feb 2 20:27:38 kjj-desktop systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
Feb 2 20:27:38 kjj-desktop systemd[1]: Stopped MySQL Community Server.
因此我很想再次删除/清除 mysql,但我敢打赌这会再次发生。
有哪位好心人能帮我吗?!哦,我希望如此……选项和耐心都用完了。我没有报名参加这个 :(
谢谢!
答案1
这个错误是因为安装了多次mysql导致的,运行命令:
ps -A|grep mysql
使用以下命令终止该进程:
sudo pkill mysql
然后运行命令:
ps -A|grep mysqld
也可以通过运行以下命令终止该进程:
sudo pkill mysqld
现在您已完全设置完毕,只需运行以下命令:
service mysql restart
mysql -u root -p
答案2
谢谢 Cristian!实际上,我自己解决了这个问题。问题是 Stacer 应用程序删除了 error.log 文件。我必须创建目录,然后更改权限。
我在这里得到的信息如何启用 MySQL 日志记录?但必须更新文件名以使其与 5.7 或当前安装的 mysql 兼容。
再次感谢。问题解决了。回去工作吧。干杯!凯尔