MySQLã®ãã¼ã¿ãã£ã¬ã¯ããªã®åæåã«ã¯ããã¾ã§ mysql_install_db ã使ããã¦ãã¾ããããMySQL 5.7ãã㯠mysqld --initialize ã使ããã¨ãæ¨å¥¨ããã¦ãã¾ãã
mysqld --initialize 㯠datadir é
ä¸ã«ãã¡ã¤ã«ããµããã£ã¬ã¯ããªãããã¨ã¨ã©ã¼çµäºãã¾ãã
# mysqld --initialize --user=mysql 2016-10-04T11:39:01.313174Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-10-04T11:39:01.313222Z 0 [ERROR] Aborting
ãªã®ã§ datadir ãã¹ãã«ã©ã«ã³ã«ãã¦å度å®è¡ãã¦ã¿ã¾ããmy.cnf ã¯ãããªå 容ã§ãdatadir ã®ä¸ã« tmpdirãInnoDBã®ãã¼ã¿ã¨ãã°ã®ãã£ã¬ã¯ããªãããæ§æã§ãã
datadir = /data/mysql tmpdir = /data/mysql/tmp innodb_data_home_dir = ibdata innodb_log_group_home_dir = iblog
# rm -fr /data/mysql/* # mysqld --initialize --user=mysql # echo $? 1 # cat /data/mysql/mysqld.err mysqld: Can't create/write to file '/data/mysql/tmp/ibSY07SU' (Errcode: 2 - No such file or directory) 2016-10-04T11:41:18.876953Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 2 2016-10-04T11:41:18.876965Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2016-10-04T11:41:18.876971Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2016-10-04T11:41:18.876975Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2016-10-04T11:41:18.876980Z 0 [ERROR] Failed to initialize plugins. 2016-10-04T11:41:18.876983Z 0 [ERROR] Aborting
/data/mysql/tmp ãåå¨ããªãã®ã§ /data/mysql/tmp/ibSY07SU ãä½ããã¨ã©ã¼çµäºãã¦ãã¾ãã
InnoDBã®ãã¼ã¿ããã°ãã£ã¬ã¯ããªã«ã¤ãã¦ãåæ§ã§ãèªåã§ã¯ãµããã£ã¬ã¯ããªãä½ã£ã¦ããã¾ããã
[ERROR] InnoDB: Operating system error number 2 in a file operation. [ERROR] InnoDB: The error means the system cannot find the path specified. [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them. [ERROR] InnoDB: File ibdata/ibdata1: 'create' returned OS error 71. Cannot continue operation [ERROR] InnoDB: Cannot continue operation.
[ERROR] InnoDB: Operating system error number 2 in a file operation. [ERROR] InnoDB: The error means the system cannot find the path specified. [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them. [ERROR] InnoDB: File iblog/ib_logfile101: 'create' returned OS error 71. [ERROR] InnoDB: Cannot create iblog/ib_logfile101 [ERROR] InnoDB: InnoDB Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again. [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Failed to initialize plugins. [ERROR] Aborting
ã¨ããããã§ãåæåã«ã¯ãµããã£ã¬ã¯ããªãå¿
è¦ãªããã§ããããµããã£ã¬ã¯ããªããã㨠mysqld --initialize ã¯ã¨ã©ã¼çµäºãã¾ãã
_人人人人人人人人人人人人人人人人人人_
ï¼ãã©ããããããããï¼ï¼ï¼ï¼ï¼ï¼ï¼ãï¼
ï¿£Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Yï¿£
éæ¹ã«æ®ãããã«ãªãã¾ããããããã¥ã¡ã³ãã«ã¡ããã¨æ¸ãã¦ããã¾ããã
As of MySQL 5.7.11, an existing data directory is permitted to be nonempty if every entry either has a name that begins with a period (.) or is named using an --ignore-db-dir option.
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
ã¨ããããã§ãäºãå¿ è¦ãªãµããã£ã¬ã¯ããªãä½ã£ã¦ããã¦ãå¿ è¦ãªã ã --ignore-db-dir ã§ç¹°ãè¿ããããæå®ããã°OKã§ãã
# rm -fr /data/mysql/* # install -d -o mysql -g mysql -m 750 /data/mysql/{tmp,ibdata,iblog} # mysqld --initialize --user=mysql --ignore-db-dir=tmp --ignore-db-dir=ibdata --ignore-db-dir=iblog # echo $? 0
è¿½è¨ 2023-03-06
--ignore-db-dir 㯠5.7 㧠deprecated ã ã£ãã®ã§ããã8.0 ã§å»æ¢ããã¦ä½¿ããªããªãã¾ããã
8.0 ã§ã¯ã©ãããã°ããã®ã§ããããããã