zoukankan      html  css  js  c++  java
  • Linux 中文件和文件夹获取 MySQL 权限(SELinux)

    今天在 Linux 系统上移动 MySQL 的数据库目录

    配置如下:

    /etc/my.cnf

    [mysqld]
    datadir=/home/mysql
    socket=/var/lib/mysql/mysql.sock

    更改完配置文件重启MYSQL的时候出现的以下问题

    110222 11:15:07 mysqld_safe Starting mysqld daemon with databases from /home/mysql
    110222 11:15:07 [Warning] Can't create test file /home/mysql/localhost.lower-test
    110222 11:15:07 [Warning] Can't create test file /home/mysql/localhost.lower-test
     /usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
    110222 11:15:07 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
    110222 11:15:07  InnoDB: Operating system error number 13 in a file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    InnoDB: File name ./ibdata1
    InnoDB: File operation call: 'open'.
    InnoDB: Cannot continue operation.
    110222 11:15:07 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

    当初以为只是文件或文件夹权限问题,把所有对应的目录和文件的权限改成读写状态...还是没用...

    在网上找了一会儿,找到解决方法了~

    解决方法如下:

    #在终端中先输入下面这一行

    chown -R mysql:mysql /home/data/mysql
    #在输入下面的一行就OK了

    chcon -R -t mysqld_db_t /home/mysql

    #重启下MYSQL试试~

    /etc/init.d/mysqld restart

  • 相关阅读:
    CF854C Planning优先队列|set
    暑假集训-8.9总结
    暑假集训-8.6总结
    AcWing 206. 石头游戏 矩阵乘法|矩阵快速幂
    暑假集训-8.5总结
    KMP 和 扩展KMP
    暑假集训-8.4总结
    暑假集训-8.3总结
    2019牛客暑期多校第二场题解FH
    AcWing 196. 质数距离
  • 原文地址:https://www.cnblogs.com/root0/p/9894639.html
Copyright © 2011-2022 走看看