2017-10-10 62 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