【问题标题】:MySQL 5.7 installation error `mysqld: Can't create/write to file '/var/lib/mysql/is_writable'`MySQL 5.7 安装错误`mysqld: Can't create/write to file '/var/lib/mysql/is_writable'`
【发布时间】:2016-05-10 02:40:59
【问题描述】:

我正在尝试在 Ubuntu 14.04 上安装 MySQL 5.7。

以下是我遵循的步骤:

rm -rf /var/lib/mysql
mkdir -p /var/lib/mysql
cd
wget http://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb
dpkg -i mysql-apt-config_0.7.2-1_all.deb
apt-get update
apt-get -y install mysql-server

除了最后一个步骤外,所有步骤都运行良好。它给了我以下错误:

mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)
2016-05-10T02:10:24.219279Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
2016-05-10T02:10:24.219530Z 0 [ERROR] Aborting

以下是错误的完整日志:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apparmor libaio1 libapparmor-perl libapparmor1 libmecab2 mysql-client
  mysql-common mysql-community-client mysql-community-server psmisc
Suggested packages:
  apparmor-profiles apparmor-docs apparmor-utils
The following NEW packages will be installed:
  apparmor libaio1 libapparmor-perl libapparmor1 libmecab2 mysql-client
  mysql-common mysql-community-client mysql-community-server mysql-server
  psmisc
0 upgraded, 11 newly installed, 0 to remove and 2 not upgraded.
Need to get 27.8 MB of archives.
After this operation, 215 MB of additional disk space will be used.
Get:1 http://repo.mysql.com/apt/ubuntu/ trusty/mysql-5.7 mysql-common amd64 5.7.12-1ubuntu14.04 [261 kB]
Get:2 http://repo.mysql.com/apt/ubuntu/ trusty/mysql-5.7 mysql-community-client amd64 5.7.12-1ubuntu14.04 [7307 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6364 B]
Get:4 http://repo.mysql.com/apt/ubuntu/ trusty/mysql-5.7 mysql-client amd64 5.7.12-1ubuntu14.04 [12.4 kB]
Get:5 http://repo.mysql.com/apt/ubuntu/ trusty/mysql-5.7 mysql-community-server amd64 5.7.12-1ubuntu14.04 [19.5 MB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libapparmor1 amd64 2.8.95~2430-0ubuntu5.3 [25.5 kB]
Get:7 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libapparmor-perl amd64 2.8.95~2430-0ubuntu5.3 [26.8 kB]
Get:8 http://archive.ubuntu.com/ubuntu/ trusty-updates/main apparmor amd64 2.8.95~2430-0ubuntu5.3 [319 kB]
Get:9 http://repo.mysql.com/apt/ubuntu/ trusty/mysql-5.7 mysql-server amd64 5.7.12-1ubuntu14.04 [12.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu/ trusty/main psmisc amd64 22.20-1ubuntu2 [53.2 kB]
Get:11 http://archive.ubuntu.com/ubuntu/ trusty/universe libmecab2 amd64 0.996-1.1 [244 kB]
Fetched 27.8 MB in 0s (35.1 MB/s)
Preconfiguring packages ...
Selecting previously unselected package libaio1:amd64.
(Reading database ... 21277 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.109-4_amd64.deb ...
Unpacking libaio1:amd64 (0.3.109-4) ...
Selecting previously unselected package mysql-common.
Preparing to unpack .../mysql-common_5.7.12-1ubuntu14.04_amd64.deb ...
Unpacking mysql-common (5.7.12-1ubuntu14.04) ...
Selecting previously unselected package mysql-community-client.
Preparing to unpack .../mysql-community-client_5.7.12-1ubuntu14.04_amd64.deb ...
Unpacking mysql-community-client (5.7.12-1ubuntu14.04) ...
Selecting previously unselected package mysql-client.
Preparing to unpack .../mysql-client_5.7.12-1ubuntu14.04_amd64.deb ...
Unpacking mysql-client (5.7.12-1ubuntu14.04) ...
Selecting previously unselected package libapparmor1:amd64.
Preparing to unpack .../libapparmor1_2.8.95~2430-0ubuntu5.3_amd64.deb ...
Unpacking libapparmor1:amd64 (2.8.95~2430-0ubuntu5.3) ...
Selecting previously unselected package libapparmor-perl.
Preparing to unpack .../libapparmor-perl_2.8.95~2430-0ubuntu5.3_amd64.deb ...
Unpacking libapparmor-perl (2.8.95~2430-0ubuntu5.3) ...
Selecting previously unselected package apparmor.
Preparing to unpack .../apparmor_2.8.95~2430-0ubuntu5.3_amd64.deb ...
Unpacking apparmor (2.8.95~2430-0ubuntu5.3) ...
Selecting previously unselected package psmisc.
Preparing to unpack .../psmisc_22.20-1ubuntu2_amd64.deb ...
Unpacking psmisc (22.20-1ubuntu2) ...
Selecting previously unselected package libmecab2.
Preparing to unpack .../libmecab2_0.996-1.1_amd64.deb ...
Unpacking libmecab2 (0.996-1.1) ...
Selecting previously unselected package mysql-community-server.
Preparing to unpack .../mysql-community-server_5.7.12-1ubuntu14.04_amd64.deb ...
Unpacking mysql-community-server (5.7.12-1ubuntu14.04) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-1ubuntu14.04_amd64.deb ...
Unpacking mysql-server (5.7.12-1ubuntu14.04) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up libaio1:amd64 (0.3.109-4) ...
Setting up mysql-common (5.7.12-1ubuntu14.04) ...
Setting up mysql-community-client (5.7.12-1ubuntu14.04) ...
Setting up mysql-client (5.7.12-1ubuntu14.04) ...
Setting up libapparmor1:amd64 (2.8.95~2430-0ubuntu5.3) ...
Setting up libapparmor-perl (2.8.95~2430-0ubuntu5.3) ...
Setting up apparmor (2.8.95~2430-0ubuntu5.3) ...
invoke-rc.d: policy-rc.d denied execution of start.
invoke-rc.d: policy-rc.d denied execution of reload.
Setting up psmisc (22.20-1ubuntu2) ...
Setting up libmecab2 (0.996-1.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up mysql-community-server (5.7.12-1ubuntu14.04) ...
mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)
2016-05-10T02:10:24.219279Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
2016-05-10T02:10:24.219530Z 0 [ERROR] Aborting

dpkg: error processing package mysql-community-server (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= 5.7.12-1ubuntu14.04); however:
  Package mysql-community-server is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mysql-community-server
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

有人可以建议我解决该错误吗? 提前致谢!

【问题讨论】:

    标签: mysql


    【解决方案1】:

    您需要确保您的数据目录归mysql 用户所有并且属于mysql 组。我之前在设置 MySQL 时也忘记了这样做。如果你这样做,它应该可以工作:

    sudo chown mysql /var/lib/mysql
    sudo chgrp mysql /var/lib/mysql
    

    这是MySQL documentation

    【讨论】:

    • 非常感谢!在运行这些命令之前,我必须使用adduser mysql 创建一个新用户mysql,但一旦完成,它就可以完美运行。
    【解决方案2】:

    Docker for Mac(本机)使这比以前容易得多,我在使用 Toolbox 时遇到了权限问题。
    https://docs.docker.com/docker-for-mac/

    【讨论】:

      猜你喜欢
      • 2020-04-20
      • 2017-12-29
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 2014-04-12
      • 1970-01-01
      相关资源
      最近更新 更多