mysql添加开机自启_初始化mysql并设置开机自动启动

1,初始化环境

useradd mysql

mkdir /3333

mkdir /3333/data

mkdir /3333/log

mkdir /3333/run

touch /3333/log/db.log

chown -R mysql:mysql /3333

2,初始化数据库,无密码

[root@db01 data]# /opt/mysql/bin/mysqld --datadir=/3333/data --user=mysql --initialize-insecure

2021-02-07T02:12:02.462057Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2021-02-07T02:12:02.773084Z 0 [Warning] InnoDB: New log files created, LSN=45790

2021-02-07T02:12:02.825583Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2021-02-07T02:12:02.887143Z 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: de29a256-68e9-11eb-b2ef-000c29a91aed.

2021-02-07T02:12:02.887685Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2021-02-07T02:12:02.888181Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

3,初始化数据库

cat >> /3333/data/my.cnf<

[mysqld]

port=3333

datadir=/3333/data

socket=/3333/mysql.sock

[mysqld_safe]

log-error=/3333/log/db.log

pid-file=/3333/run/db.pid

EOF

4,设置开机自动启动脚本

[root@db01 support-files]# pwd

/opt/mysql/support-files

[root@db01 support-files]# cp mysql.server mysql3333

[root@db01 support-files]# chmod +x mysql3333

support-files 文件设置开机启动脚本:

1,datadir=/3333/data

2,lockdir='/3333'

3,启动参数文件my.cnf,放到datadir目录(extra_args="-e $datadir/my.cnf)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值