php 初始化mysql目录错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37644118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Initializing mysql directory error
提问by Pay C.
I checked this page: http://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html
我检查了这个页面:http: //dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html
mysql_install_db
is removed, however, when I use mysqld --initialize
. It promotes these errors and warning.
mysql_install_db
但是,当我使用mysqld --initialize
. 它促进了这些错误和警告。
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting
The first one can be ignored according to this:How to enable explicit_defaults_for_timestamp?
第一个可以根据这个忽略:如何启用explicit_defaults_for_timestamp?
I don't know how to solve the second problem.
我不知道如何解决第二个问题。
采纳答案by Eugene Lisitsky
Pls, read error carefully:
请仔细阅读错误:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[错误] --initialize 指定,但数据目录中有文件。中止。
Your directory is not empty. You have to remove all the contents of it or choose another one.
您的目录不为空。您必须删除其中的所有内容或选择其他内容。
回答by Ghasem Pahlavan
Its usually means your data directory is not empty. If you remove or rename the data directory and the problem still exist, check your config file /etc/my.cnf
and delete validate_password_policy
variable in the initialize step. after starting the server you can set this variable to any things you want.
它通常意味着您的数据目录不为空。如果您删除或重命名数据目录并且问题仍然存在,请检查您的配置文件/etc/my.cnf
并validate_password_policy
在初始化步骤中删除变量。启动服务器后,您可以将此变量设置为您想要的任何内容。
回答by Ashik Ahmed
I faced the sample problem. i renamed the container directory from
我遇到了样本问题。我重命名了容器目录
/var/lib/mysql
/var/lib/mysql
to
到
/var/lib/minesql or some different name
/var/lib/minesql 或一些不同的名称
. Now the container is started.
. 现在容器已启动。
Previous Command:
上一个命令:
docker container run --name=mysql -d -e MYSQL_ROOT_PASSWORD=abc1234 -e MYSQL_DATABASE=sample -e MYSQL_USER=ashik -e MYSQL_PASSWORD=abc123 -v mysql_volume:/var/lib/mysql mysql
Working Command:
工作命令:
docker container run --name=mysql -d -e MYSQL_ROOT_PASSWORD=abc1234 -e MYSQL_DATABASE=sample -e MYSQL_USER=ashik -e MYSQL_PASSWORD=abc123 -v mysql_volume:/var/lib/minesql mysql
回答by nur zazin
just remove /data directory. this is worked for me :
只需删除 /data 目录。这对我有用:
as simple like this :
就像这样简单:
image: mysql:5.7
volumes:
- ./db:/var/lib/mysql
and make sure your "./db" directory is empty.
并确保您的“./db”目录为空。
回答by Turan Zamanl?
Disable SElinux.
禁用 SElinux。
Setenforce 0
Also create log directory in /var/logs/ mysql folder It have to mysql user owner
还要在 /var/logs/ mysql 文件夹中创建日志目录它必须是 mysql 用户所有者
cd /var/log/
mkdir mysql
chown -R mysql:mysql mysql/
then change log direcotry in /etc/my.cnf
然后更改 /etc/my.cnf 中的日志目录
回答by Abdallah Okasha
In my case the solution was to edit volume directory in my docker-compose.yml
在我的情况下,解决方案是在我的 docker-compose.yml
from:
从:
image: mysql:5.6
volumes:
- ./db:/var/lib/mysql/data
To
到
image: mysql:5.6
volumes:
- ./db_data:/var/lib/mysql/data
And run again
sudo docker-compose build
然后再次运行
sudo docker-compose build
sudo docker-compose up
sudo docker-compose up
And then you may need to run migrate sudo docker-compose run web rake db:create
for my Rails app.
然后你可能需要sudo docker-compose run web rake db:create
为我的Rails 应用程序运行 migrate 。
回答by why
If you're running Docker Desktop for Mac, this could be because Docker.qcow2
has exceeded it's maximum size. This file has a default size of 64GB. You can resize it, or for a more drastic solution, delete it:
如果您正在运行 Mac 版 Docker 桌面,这可能是因为Docker.qcow2
已超出其最大大小。此文件的默认大小为 64GB。您可以调整它的大小,或者对于更激烈的解决方案,将其删除:
rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
References:
参考:
- Source of this solution: No space left on device error
- SO: What is Docker.qcow2
- Github Issue: Docker.qcow2 never shrinks
- Blog post: The Mystery of Docker and The Disk-Eating Cow
- 此解决方案的来源:设备错误上没有剩余空间
- SO:什么是 Docker.qcow2
- Github 问题:Docker.qcow2 永不收缩
- 博客文章:Docker 之谜和吃磁盘的牛