12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-11-26 22:07:34
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
问题描述在macosx下如果指定本地目录替换/var/lib/mysql,运行时会出现文件权限的错误,导致mysqld无法正常运行Creatingmysql_test-mysql_1Attachingtomysql_test-mysql_1test-
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
问题描述
在macosx下如果指定本地目录替换/var/lib/mysql,运行时会出现文件权限的错误,导致mysqld无法正常运行
Creatingmysql_test-mysql_1Attachingtomysql_test-mysql_1test-mysql_1|Initializingdatabasetest-mysql_1|2016-03-23T04:32:37.437789Z0[Warning]Settinglower_case_table_names=2becausefilesystemfor/var/lib/mysql/iscaseinsensitivetest-mysql_1|2016-03-23T04:32:37.466955Z0[ERROR]InnoDB:Operatingsystemerrornumber13inafileoperation.test-mysql_1|2016-03-23T04:32:37.467828Z0[ERROR]InnoDB:Theerrormeansmysqlddoesnothavetheaccessrightstothedirectory.test-mysql_1|2016-03-23T04:32:37.468824Z0[ERROR]InnoDB:Operatingsystemerrornumber13inafileoperation.test-mysql_1|2016-03-23T04:32:37.468912Z0[ERROR]InnoDB:Theerrormeansmysqlddoesnothavetheaccessrightstothedirectory.test-mysql_1|2016-03-23T04:32:37.470280Z0[ERROR]InnoDB:Cannotopendatafile'./ibdata1'test-mysql_1|2016-03-23T04:32:37.470309Z0[ERROR]InnoDB:Couldnotopenorcreatethesystemtablespace.Ifyoutriedtoaddnewdatafilestothesystemtablespace,anditfailedhere,youshouldnoweditinnodb_data_file_pathinmy.cnfbacktowhatitwas,andremovethenewibdatafilesInnoDBcreatedinthisfailedattempt.InnoDBonlywrotethosefilesfullofzeros,butdidnotyetusetheminanyway.Butbecareful:donotremoveolddatafileswhichcontainyourpreciousdata!test-mysql_1|2016-03-23T04:32:37.470317Z0[ERROR]InnoDB:InnoDBDatabasecreationwasabortedwitherrorCannotopenafile.Youmayneedtodeletetheibdata1filebeforetryingtostartupagain.test-mysql_1|2016-03-23T04:32:38.073222Z0[ERROR]Plugin'InnoDB'initfunctionreturnederror.test-mysql_1|2016-03-23T04:32:38.073268Z0[ERROR]Plugin'InnoDB'registrationasaSTORAGEENGINEfailed.test-mysql_1|2016-03-23T04:32:38.073283Z0[ERROR]Failedtoinitializeplugins.test-mysql_1|2016-03-23T04:32:38.073289Z0[ERROR]Abortingtest-mysql_1|mysql_test-mysql_1exitedwithcode1
解决方案
创建在scripts目录下mysqld启动脚本
#!/bin/bash#Fromhttps://github.com/docker-library/mysql/issues/99set-e#failonanyerrorecho'*WorkingaroundpermissionerrorsinDockeronMaclocallybymakingsurethat"mysql"usesthesameuidandgidasthehostvolume'TARGET_UID=$(stat-c"%u"/var/lib/mysql)echo'--Settingmysqlusertouseuid'$TARGET_UIDusermod-o-u$TARGET_UIDmysql||trueTARGET_GID=$(stat-c"%g"/var/lib/mysql)echo'--Settingmysqlgrouptousegid'$TARGET_GIDgroupmod-o-g$TARGET_GIDmysql||trueechoecho'*StartingMySQL'chown-Rmysql:root/var/run/mysqld//entrypoint.shmysqld--user=mysql--console
创建docker-compose.py,指定run-mysqld.sh脚本为容器入口
test-mysql:image:mysqlports:-"3306:3306"volumes:-/localhost/mysql/data:/var/lib/mysql-./scripts/run-mysqld.sh:/run-mysqld.shenvironment:-MYSQL_DATABASE=play-MYSQL_USER=play-MYSQL_PASSWORD=play-MYSQL_ROOT_PASSWORD=123456entrypoint:/run-mysqld.sh
运行docker-compose up命令,启动容器
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19