部署LNMP架构时安装MySQL的报错(--initialize specified but the data directory has files in it. Aborting.)!

MySQL数据库装完了,准备初始化数据库时出现问题“–initialize specified but the data directory has files in it. Aborting.”

[root@localhost mysql]# bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2021-06-22T16:41:37.699189Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-22T16:41:37.700235Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-06-22T16:41:37.700254Z 0 [ERROR] Aborting

错误原因,这是我的mysql数据库已经初始化过,但是代码敲错出现问题,而我们不能再用这个进行初始化,解决方法:

vim /etc/my.cnf      #找到以下位置的文件,并删除它

在这里插入图片描述

[root@localhost mysql]# rm -rf /usr/local/mysql/data

#### 再重新初始化系统即可
[root@localhost mysql]# bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2021-06-22T16:56:03.767918Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-22T16:56:04.014610Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-06-22T16:56:04.062964Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-06-22T16:56:04.119111Z 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: baf795ee-d37a-11eb-80d4-000c2908133d.
2021-06-22T16:56:04.120460Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-06-22T16:56:04.121173Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值