Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the problem that mysql can not start by modifying the default path of the database

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Preface

When mysql modifies the default path of the database, the service cannot be started. Check the log and find an error reporting file permissions.

For the changed directory, mysql has been set to the owner of the directory. And everything is fine when you start the database directly under the command line.

Sacrifice the omnipotent Google, and finally found the reason in a foreigner's post-SELINUX strategy problem!

All backend services need to have the corresponding permission to the corresponding directory, and the default path / var/lib/mysql of mysql has added a corresponding policy. After modifying the path, there is no corresponding policy, resulting in the background process reading files blocked by selinux, resulting in a permission error!

The methods are as follows:

Mysql, the method is:

Chcon-R-t mysqld_db_t / db/mysql

If it is APACHE, the method is:

# chcon-R-h-t httpd_sys_content_t / www/web/

With chcon command help

Chcon command: modify the security context of the object (file) (such as: user: role: type: security level).

Command format:

Chcon [OPTIONS...] CONTEXT FILES... ..

Chcon [OPTIONS...] -reference=PEF_FILES FILES

Description:

CONTEXT is the security context to be set

FILES objects (files)

-- reference reference object

PEF_FILES reference file context

The FILES application reference file context is my context.

OPTIONS is as follows:

-f forced execution

-R recursively modifies the security context of an object

-r ROLE modifies the configuration of the security context role

-t TYPE modifies the configuration of the security context type

-u USER modifies the configuration of the security context user

-v displays lengthy information

-l,-- range=RANGE modifies the security level in the security context

Mysql, the method is:

Chcon-R-t mysqld_db_t / db/mysql

Example

If you want to share this ftp with anonymous users, you need to open the following:

Chcon-R-t public_content_t / var/ftp

If you want the FTP directory you set up to upload files, SELINUX needs to be set up:

Chcon-t public_content_rw_t / var/ftp/incoming

Allow user HHTP to access their home directory, which is limited to the user's home directory home page:

Setsebool-P httpd_enable_homedirs 1 chcon-R-t httpd_sys_content_t ~ user/public_html

If you want to share the samba directory with other users, you need to set:

Chcon-t samba_share_t / directory

When sharing the rsync directory:

Chcon-t public_content_t / directories

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 295

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report