摘要:?jiǎn)栴}描述在下如果指定本地目錄替換,運(yùn)行時(shí)會(huì)出現(xiàn)文件權(quán)限的錯(cuò)誤,導(dǎo)致無法正常運(yùn)行解決方案創(chuàng)建在目錄下啟動(dòng)腳本創(chuàng)建,指定腳本為容器入口運(yùn)行命令,啟動(dòng)容器
問題描述
在macosx下如果指定本地目錄替換/var/lib/mysql,運(yùn)行時(shí)會(huì)出現(xiàn)文件權(quán)限的錯(cuò)誤,導(dǎo)致mysqld無法正常運(yùn)行
Creating mysql_test-mysql_1 Attaching to mysql_test-mysql_1 test-mysql_1 | Initializing database test-mysql_1 | 2016-03-23T04:32:37.437789Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive test-mysql_1 | 2016-03-23T04:32:37.466955Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. test-mysql_1 | 2016-03-23T04:32:37.467828Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. test-mysql_1 | 2016-03-23T04:32:37.468824Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. test-mysql_1 | 2016-03-23T04:32:37.468912Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. test-mysql_1 | 2016-03-23T04:32:37.470280Z 0 [ERROR] InnoDB: Cannot open datafile "./ibdata1" test-mysql_1 | 2016-03-23T04:32:37.470309Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data! test-mysql_1 | 2016-03-23T04:32:37.470317Z 0 [ERROR] InnoDB: InnoDB Database creation was aborted with error Cannot open a file. You may need to delete the ibdata1 file before trying to start up again. test-mysql_1 | 2016-03-23T04:32:38.073222Z 0 [ERROR] Plugin "InnoDB" init function returned error. test-mysql_1 | 2016-03-23T04:32:38.073268Z 0 [ERROR] Plugin "InnoDB" registration as a STORAGE ENGINE failed. test-mysql_1 | 2016-03-23T04:32:38.073283Z 0 [ERROR] Failed to initialize plugins. test-mysql_1 | 2016-03-23T04:32:38.073289Z 0 [ERROR] Aborting test-mysql_1 | mysql_test-mysql_1 exited with code 1解決方案
創(chuàng)建在scripts目錄下mysqld啟動(dòng)腳本
#!/bin/bash # From https://github.com/docker-library/mysql/issues/99 set -e # fail on any error echo "* Working around permission errors in Docker on Mac locally by making sure that "mysql" uses the same uid and gid as the host volume" TARGET_UID=$(stat -c "%u" /var/lib/mysql) echo "-- Setting mysql user to use uid "$TARGET_UID usermod -o -u $TARGET_UID mysql || true TARGET_GID=$(stat -c "%g" /var/lib/mysql) echo "-- Setting mysql group to use gid "$TARGET_GID groupmod -o -g $TARGET_GID mysql || true echo echo "* Starting MySQL" chown -R mysql:root /var/run/mysqld/ /entrypoint.sh mysqld --user=mysql --console
創(chuàng)建docker-compose.py,指定run-mysqld.sh腳本為容器入口
test-mysql: image: mysql ports: - "3306:3306" volumes: - /localhost/mysql/data:/var/lib/mysql - ./scripts/run-mysqld.sh:/run-mysqld.sh environment: - MYSQL_DATABASE=play - MYSQL_USER=play - MYSQL_PASSWORD=play - MYSQL_ROOT_PASSWORD=123456 entrypoint: /run-mysqld.sh
運(yùn)行docker-compose up命令,啟動(dòng)容器
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://m.specialneedsforspecialkids.com/yun/26552.html
摘要:變量如果用戶目錄下存在,比如我的,則添加一行否則新建然后在添加上文在中輸入如果可以看到版本號(hào),則安裝成功。 PhantomJS 安裝 showImg(https://segmentfault.com/img/bVL0NY?w=408&h=252); Mac OS X && Windows 1、PhantomJS下載地址 按照系統(tǒng)下載對(duì)應(yīng)的版本, macOS 下載: phantomjs...
摘要:變量如果用戶目錄下存在,比如我的,則添加一行否則新建然后在添加上文在中輸入如果可以看到版本號(hào),則安裝成功。 PhantomJS 安裝 showImg(https://segmentfault.com/img/bVL0NY?w=408&h=252); Mac OS X && Windows 1、PhantomJS下載地址 按照系統(tǒng)下載對(duì)應(yīng)的版本, macOS 下載: phantomjs...
閱讀 3747·2023-04-25 18:41
閱讀 1180·2021-11-11 16:55
閱讀 1840·2021-09-22 15:54
閱讀 3075·2021-09-22 15:51
閱讀 3551·2019-08-30 15:55
閱讀 1947·2019-08-30 14:19
閱讀 1287·2019-08-29 10:57
閱讀 1708·2019-08-29 10:56