Please read "Security" section of the manual to find out how to run mysqld as root!错误解决

环境: CentOSmysql

MySQL版本:5.6.30spring

开发环境:jdk8,spring+MyBatis+jtasql

报错缘由:作添加Date类型操做是,出现时区问题,致使存入数据库的时间与当北京时间相差8小时,后来采用网上解决方法:数据库

 

以管理员身份登录mysql 执行如下语句安全

mysql > SET time_zone = '+8:00';   # 此为北京时,咱们所在东8区bash

   mysql> flush privileges;   # 当即生效less

在重启mysql时,启动失败,错误信息为pid未找到。this

 

---------------------------------------------------------------------------解决方法:.net

 

在虚拟机中安装了CentOS时安装了Nami版的Rendmine,没有设置MySQL自动启动,手动启动时出现 Please read "Security" section of the manual to find out how to run mysqld as root!错误,根据提示,查了 /opt/redmine-1.2.1-1/mysql/docs/mysql.info的Security部分,发现是由于MySQL为了安全,不但愿root用户直接启动mysql。下面是文档中的原文:server

 

 *Never run the MySQL server as the Unix `root' user. This is
  extremely dangerous, because any user with the `FILE' privilege is
  able to cause the server to create files as `root' (for example,
  `~root/.bashrc'). To prevent this, *Note `mysqld': mysqld. refuses
  to run as `root' unless that is specified explicitly using the
  `--user=root' option.

永远不要使用root账号启动MySQL Server。这样作很微笑,由于拥有FILE'权限的用户会使得MySQL Server使用root账户建立文件(好比,~root/.bashrc),为了防止相似的事情发生,mysqld默认拒绝用户使用root账户启动,但root用户能够经过在命令后面加上"--user=root"选项来强行启动mysqld。

  *Note `mysqld': mysqld. can (and should) be run as an ordinary,
  unprivileged user instead. You can create a separate Unix account
  named `mysql' to make everything even more secure. Use this
  account only for administering MySQL. To start *Note `mysqld':
  mysqld. as a different Unix user, add a `user' option that
  specifies the user name in the `[mysqld]' group of the `my.cnf'
  option file where you specify server options. For example:

          [mysqld]
          user=mysql

   与使用root用户启动mysqld相比,更好的方法是使用一个普通的、没有高级权限的用户账户容许mysqld,例如建立一个名为mysql的用户账户来专门管理MySQL。使用其账启

   动MySQL的方法是在mysqld命令后面加上一个用户选项,这个用户属于mysqld用户组而且位于my.cnf配置文件中。例如在建立mysql账户后,能够将下面的内容添加到my.cnf文

   件中:

          [mysqld]

user=mysql

  This causes the server to start as the designated user whether you
  start it manually or by using *Note `mysqld_safe': mysqld-safe. or
  *Note `mysql.server': mysql-server. For more details, see *Note
  changing-mysql-user::.

这个选项可使你使用指定的用户账户启动MySQL,不管是mysqld_safe仍是mysql.server命令,均可以使用。

  Running *Note `mysqld': mysqld. as a Unix user other than `root'
  does not mean that you need to change the `root' user name in the
  `user' table. _User names for MySQL accounts have nothing to do
  with user names for Unix accounts_.

不要使用Unix的root用户启动并不意味着你要修改MySQL中的user表中的root用户名,由于Unix的root账户和MySQL的root账户没有什么关系。

相关文章
相关标签/搜索