MySQL 致命错误:请阅读手册的“安全”部分以了解如何以 root 身份运行 mysqld

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25700971/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:01:35  来源:igfitidea点击:

Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root

mysqlsqlmy.cnf

提问by Mona Jalal

I am not sure how to fix this:

我不知道如何解决这个问题:

dyn-72-33-214-45:python mona$ sudo /usr/local/mysql/bin/mysqld stop
2014-09-06 09:49:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-06 09:49:04 22992 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.6.15-osx10.7-x86_64/data/ is case insensitive
2014-09-06 09:49:04 22992 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2014-09-06 09:49:04 22992 [ERROR] Aborting

2014-09-06 09:49:04 22992 [Note] Binlog end
2014-09-06 09:49:04 22992 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

回答by Mise

I'm using OS X (Yosemite) and this error happened to me when I upgraded from Mavericks to Yosemite. It was solved by using this command

我正在使用 OS X (Yosemite),当我从 Mavericks 升级到 Yosemite 时发生了这个错误。用这个命令解决了

sudo /usr/local/mysql/support-files/mysql.server start

回答by MrTux

The MySQL daemon should not be executed as the system user rootwhich (normally) do not has any restrictions.

MySQL 守护进程不应作为系统用户执行,系统用户root(通常)没有任何限制。

According to your cli, I suppose you wanted to execute the initscript instead:

根据您的 cli,我想您想改为执行 initscript:

sudo /etc/init.d/mysql stop

Another way would be to use the mysqladmin tool (note, rootis the MySQL root user here, not the system rootuser):

另一种方法是使用 mysqladmin 工具(注意,root这里是 MySQL 根用户,而不是系统 root用户):

/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown

回答by Saurabh Chandra Patel

Try this for Amazon Linux AMIor for centOS

Amazon Linux AMIcentOS 上试试这个

sudo service mysqld restart

回答by xiaojueguan

you might try this if you logged in with root:

如果你用 root 登录,你可以试试这个:

mysqld --user=root

回答by mondrey

How i resolved this was following the 4th point in this url: https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html

我如何解决这个问题是在这个 url 的第 4 点之后:https: //dev.mysql.com/doc/refman/8.0/en/changed-mysql-user.html

  1. Edit my.cnf
  2. Add user = rootunder under [mysqld] group of the file
  1. 编辑 my.cnf
  2. user = root在文件的[mysqld]组下添加

If this doesn't work then make sure you have changed the password from default.

如果这不起作用,请确保您已更改默认密码。

回答by Donal

osx could be using launchctl to launch mysql. Try this:

osx 可能正在使用 launchctl 来启动 mysql。尝试这个:

sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

回答by Andy Stutzman

Donal had the right solution for me. However, the updated plistname for 2017 is

多纳尔为我提供了正确的解决方案。但是,plist2017 年的更新名称是

com.oracle.oss.mysql.mysqld.plist.

回答by Leo Mago

in my case (RHEL7 and MariaDB) this works.

在我的情况下(RHEL7 和 MariaDB)这是有效的。

sudo systemctl restart mariadb

回答by antoni

On top of @mise's answer, After I installed MacOS Mojave, I also had to change files ownership on all my MAMP directory and contents).

除了@mise 的回答之外, 在我安装 MacOS Mojave 之后,我还必须更改所有 MAMP 目录和内容的文件所有权)。

From the Finder, I went in Application/MAMP, showed files info (cmd+ i) and in permissions section added myself with read & write perms, then from the little gear applied to all the children.

我从 Finder 进入Application/MAMP,显示文件信息 ( cmd+ i),并在权限部分添加了我自己的读写权限,然后从应用于所有孩子的小装备开始。

回答by Hammad Khan

The correct answer that worked for me on CentOS is

在 CentOS 上对我有用的正确答案是

/etc/init.d/mysql restart

which is an init script and not /etc/init.d/mysqld restart, which is binary

这是一个init脚本而不是/etc/init.d/mysqld restart,这是二进制的

The is in fact comment of @MrTux on the question which worked for me. It took quite a bit of my time hence posting it as answer.

事实上,@MrTux 对这个对我有用的问题的评论。我花了很多时间,因此将其发布为答案。