2017-10-10 88 views
1

我想在与/ usr/local/mysql不同的地方安装mysql。 运行命令'sudo bin/mysqld --defaults-file =/home/hadoop/app/mysql-5.7.19 -linux-glibc2.12-x86_64/my.cnf --initialize --user = mysql'时,得到以下错误:在Centos7中安装mysql 5.7.19,得到权限错误

`2017-10-10T02:21:29.369158Z 0 [ERROR] Aborting 
`2017-10-10T02:21:27.717508Z 0 [Warning] TIMESTAMP with implicit DEFAULT 
`value is deprecated. Please use --explicit_defaults_for_timestamp server 
`option (see documentation for more details). 
`2017-10-10T02:21:29.109331Z 0 [Warning] InnoDB: New log files created, LSN=45790 
`2017-10-10T02:21:29.272647Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 
`2017-10-10T02:21:29.347131Z 0 [Warning] No existing UUID has been found, so 
`we assume that this is the first time that this server has been started. Generating a new UUID: b97c8f3c-ad61-11e7-a737-000c299b2d06. 
`2017-10-10T02:21:29.351277Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 
`2017-10-10T02:21:29.357864Z 1 [Note] A temporary password is generated for [email protected]: Pl)v)1&Zhl+D 
`2017-10-10T02:21:29.369007Z 1 [ERROR] 1 Can't create/write to file '/home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64/data/mysql/db.MYI' (Errcode: 13 - Permission denied) 
`2017-10-10T02:21:29.369158Z 0 [ERROR] Aborting 

`2017-10-10T02:21:29.496351Z 0 [ERROR] InnoDB: Cannot open '/home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64/data/ib_buffer_pool.incomplete' for writing: Permission denied` 

的my.cnf:

[mysqld] 
basedir=/home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64 
datadir=/home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64/data 
port=3307 
character-set-server=utf8 
server_id=1 

回答

1

您正在运行MySQL守护程序为MySQL用户(--user=mysql)。但是,您正在给它提供一个存在于hadoop用户主目录中的路径。 mysql用户无权访问hadoop主目录。

1

mysql用户应该有,read, write, execute许可

chown -R mysql.mysql /home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64/ 

OR

如果你想通过2用户使用,那么使用setfacl

setfacl -R -m u:mysql:rwx -m u:some_other_user:rw /home/hadoop/app/mysql-5.7.19-linux-glibc2.12-x86_64/ 

,如果你想给目录然后代替:u使用:g