MySQL 初始化命令出错
[root@bi mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/hadoop/data/mysql
[root@bi mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/hadoop/data/mysql
2023-02-23T12:47:49.502378Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-23T12:47:49.502420Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2023-02-23T12:47:49.502423Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2023-02-23T12:47:49.728116Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-23T12:47:49.798465Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-23T12:47:49.862328Z 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: 47b19cfe-b378-11ed-9c75-5254004fe427.
2023-02-23T12:47:49.866225Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-23T12:47:49.866530Z 1 [Note] A temporary password is generated for root@localhost: o24MtLg,
2023-02-23T12:47:49.875064Z 1 [ERROR] 1 Can't create/write to file '/home/hadoop/data/mysql/mysql/db.MYI' (Errcode: 13 - Permission denied)
2023-02-23T12:47:49.875114Z 0 [ERROR] Aborting
2023-02-23T12:47:49.975434Z 0 [ERROR] InnoDB: Cannot open '/home/hadoop/data/mysql/ib_buffer_pool.incomplete' for writing: Permission denied
解决:
更改 hadoop 目录权限
# 更改权限
chmod -R 775 /home/hadoop/
# 删除目录下内容
rm -rf /home/hadoop/data/mysql/*
# 重新初始化
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/hadoop/data/mysql