mysql がデータ ディレクトリを変更した後、次のエラーを報告し始めます: File './binlog.index' not found (OS errno 13 - Permission denied)

問題の説明:

centos7 に mysql をインストールした後、データの移行を行うときに、データ ディレクトリを新しいアドレスにポイントし、systemctl restart mysqldmysql を次のコマンドで起動すると失敗します。

ログ /var/log/mysqld.log を確認し、エラー メッセージが次のようになっていることを確認します。

2023-05-03T08:28:50.048884Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/sdb/mysqldata/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-03T08:28:50.049000Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 18157
2023-05-03T08:28:50.052848Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/sdb/mysqldata/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-03T08:28:50.052860Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /mnt/sdb/mysqldata/mysql/ is case insensitive
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-05-03T08:28:50.054952Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-03T08:28:50.055419Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL.

問題が解決しました:

#临时关闭selinux防火墙
1.[root@localhost mysql] setenforce 0
#永久关闭:vim /etc/sysconfig/selinux,将selinux=cnforcing改为selinux=disable
2.[root@localhost mysql] vim /etc/sysconfig/selinux 

ここに画像の説明を挿入

SELinuxについて

SELinuxとは

SELinux (Security-Enhanced Linux) は、国家安全保障局 (NSA) による強制アクセス制御の実装であり、Linux の歴史の中で最も優れた新しいセキュリティ サブシステムです。
selinux (セキュリティ強化 Linux) Linux カーネル モジュールであり、Linux のセキュリティ サブシステムであるセキュリティ強化 Linux。

setenforce 0 の効果

SELinux を permissive モードにして、selinux ファイアウォールを一時的に閉じ、
永続的に閉じることを示します。コマンド vi /etc/selinux/config を入力し、SELINUX=enforcing を SELINUX=disabled に変更し、保存して終了します。

SELinux の動作モード

モデル 説明
強制する 強制モードでは、SELinux ルールの違反がブロックされ、ログに記録されます
寛大な Permissive モード。SELinux ルールの違反は、デバッグ用のログにのみ記録されます。
無効 SELinuxを閉じる

おすすめ

転載: blog.csdn.net/qq_29864051/article/details/130473784