AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 981403
Accepted
Joel Deleep
Joel Deleep
Asked: 2019-08-31 22:39:56 +0800 CST2019-08-31 22:39:56 +0800 CST 2019-08-31 22:39:56 +0800 CST

无法启动 MySQL 社区服务器

  • 772

检查 my-sql 的状态时显示以下错误。

操作系统:Ubuntu 18.04.3

Mysql:mysql Ver 14.14 Distrib 5.7.27,适用于 Linux (x86_64),使用 EditLine 包装器

mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-08-31 08:27:11 CEST; 1min 12s ago
  Process: 18000 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

Aug 31 08:27:11 myserver systemd[1]: mysql.service: Control process exited, code=exited status=1
Aug 31 08:27:11 myserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 08:27:11 myserver systemd[1]: Failed to start MySQL Community Server.
Aug 31 08:27:11 myserver systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 31 08:27:11 myserver systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Aug 31 08:27:11 myserver systemd[1]: Stopped MySQL Community Server.
Aug 31 08:27:11 myserver systemd[1]: mysql.service: Start request repeated too quickly.
Aug 31 08:27:11 myserver systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 08:27:11 myserver systemd[1]: Failed to start MySQL Community Server.

我尝试开始使用以以下错误结束的 mysqld 命令

mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2019-08-31T12:51:57.596969Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-31T12:51:57.597359Z 0 [ERROR] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2019-08-31T12:51:57.597485Z 0 [ERROR] Aborting

2019-08-31T12:51:57.597607Z 0 [Note] Binlog end

我的.cnf

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

# Here is entries for some specific programs
# The following values assume you have at least 32M ram
ubuntu
  • 3 3 个回答
  • 47770 Views

3 个回答

  • Voted
  1. Best Answer
    Dave Sherohman
    2019-09-02T00:24:57+08:002019-09-02T00:24:57+08:00

    直接运行时在控制台上遇到的错误mysqld包括:

    2019-08-31T12:51:57.597359Z 0 [错误] 无法访问 --secure-file-priv 的目录。请确保该目录存在并且可以被 MySQL 服务器访问。提供的值:/var/lib/mysql-files

    那是你的问题。

    要解决它,首先检查您mysqld尝试运行的用户;这将是默认 Debian 安装中的用户“mysql”(我假设它应该与 Ubuntu 相同);要验证这一点,请检查/etc/mysql/my.cnf并查找“user = xxx”行。

    一旦您知道用户mysqld正在尝试以什么身份运行,请检查该目录是否/var/lib/mysql-files存在(sudo mkdir /var/lib/mysql-files如果不存在)并且归用户mysqld运行身份所有(sudo chown mysql /var/lib/mysql-files如果不存在;将chown命令中的“mysql”替换为正确的用户名如果您配置为以其他用户身份运行)。

    然后再试sudo mysqld一次,您应该可以成功mysqld启动,或者(如果您的设置存在其他问题)一个新的和不同的错误消息。

    • 4
  2. Raunak Ritesh
    2021-07-16T00:27:46+08:002021-07-16T00:27:46+08:00

    对我来说,我使用 Stacer 等工具运行了一些缓存清除操作以释放空间,然后 MySQL 开始出现问题。

    使用它首先获得一些线索

    grep mysql /var/log/syslog | grep ERROR
    

    如果错误说,无法打开文件'/var/log/mysql/error.log'进行错误记录:没有这样的文件或目录 ,那么很明显,日志文件已被清理。

    使用它首先创建 MySQL 目录并授予 MySQL 使用该文件夹的所有权限。

    > sudo mkdir /var/log/mysql
    > sudo chown -R mysql:mysql /var/log/mysql
    > sudo service mysql restart
    

    此解决方案与 my.cnf 文件无关,对数据完全安全。

    • 1
  3. asktyagi
    2019-09-03T19:52:59+08:002019-09-03T19:52:59+08:00

    检查下面。

    1. 检查文件是否存在。
    2. 检查文件权限。
    3. 如果启用了 Selinux,请使用以下方法修复它。

      $ semanage fcontext -a -e /var/lib/mysql /var/lib/mysql-files

      $ restorecon -R /var/lib/mysql-files

      确保 /var/lib/mysql 为空,然后尝试启动服务器:

      $ 服务 mysqld 启动

    检查此链接也可能有帮助https://askubuntu.com/questions/835541/mysql-install-db-on-ubuntu-16-04

    • 0

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve