gpt4 book ai didi

MySQL 8.0 Ubuntu 服务器在移动 datadir 后无法启动

转载 作者:行者123 更新时间:2023-12-04 09:22:30 31 4
gpt4 key购买 nike

我在 Ubuntu (18.04) 上有一个 MySQL 服务器。数据库正在增长,我向系统添加了另一个磁盘 (sdb1)。移动数据目录后服务器无法启动。
新磁盘安装在 /mnt/tb .我试图将 MySQL datadir 移动到新磁盘,所以我关闭了服务器并复制了具有权限的目录:cp -rp /var/lib/mysql /mnt/tb/ .我还编辑了/etc/mysql/mysql.conf.d/mysqld.cnf所以 datadir 是新的路径。
但是我无法使用新目录启动服务器。如果我切换回 /var/lib/mysql路径,服务器可以启动。这两个目录具有相同的用户/组读/写权限。 Ubuntu 服务器没有安装 SELinux。
这是我的 error.log 两次尝试启动服务器。第一个成功 /var/lib/mysql第二个失败了/mnt/tb/mysql .我读过 OS errno 13 - Permission denied 之前。我以为是找不到binlog文件所以我加了log_bin_basename = /mnt/tb/mysql/binlog在.cnf 文件中。还是找不到binlog.index .

2020-07-24T09:13:36.223195Z 0 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2020-07-24T09:13:36.223250Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 3249
2020-07-24T09:13:40.341593Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-24T09:14:21.929887Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-24T09:14:22.355022Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2020-07-24T09:14:22.464814Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-07-24T09:14:22.464999Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-07-24T09:14:22.484964Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2020-07-24T09:17:10.464004Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.21).
2020-07-24T09:17:34.911849Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2020-07-24T09:19:08.547269Z 0 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2020-07-24T09:19:08.547324Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 3480
2020-07-24T09:19:08.550104Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/tb/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2020-07-24T09:19:08.550117Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /mnt/tb/mysql/ is case insensitive
2020-07-24T09:19:08.550686Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-07-24T09:19:08.550814Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.
不知道是哪一部分出错了。感谢您的任何建议!

最佳答案

阻止 MySQL 初始化的问题是 AppArmor,它是一个类似于 SELinux 的强制访问控制 (MAC) 系统。有3种方法来处理它:

  • 修改/etc/apparmor.d/usr.sbin.mysqld , 更改 /var/lib/mysql到自定义路径,然后重新加载 apparmor
  • 禁用 mysql 的 apparmor
     sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
    apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld
  • 完全禁用 apparmor
    sudo systemctl disable apparmor
  • 关于MySQL 8.0 Ubuntu 服务器在移动 datadir 后无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63075272/

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