【问题标题】:Trying to set MySQL root password results in error尝试设置 MySQL root 密码会导致错误
【发布时间】:2014-02-01 23:31:18
【问题描述】:

我对 MySQL 和 Debian 还是很陌生,但最近几天读了很多书。

我有一个要用于 Wordpress 的虚拟机的 root 帐户。我读到的一件事是我应该用密码保护 MySQL,因为默认情况下 root 用户不需要密码。

我读到有人这样做:

 mysql> mysqladmin -u root password mypassword;

但这给了我以下错误:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that     corresponds to your MySQL server version for the right syntax to use near 'mysqladmin -u     root password mypassword' at line 1

【问题讨论】:

  • 您是否尝试过直接从 shell 运行命令,而不是在 mysql 中运行?
  • 这可能与它有关。我重新启动了我的 ssh 连接并尝试了更多,终于成功了。不完全确定是什么使它起作用。
  • scottsanders 是对的,你不要从 mysql> shell 运行它——而是直接从终端运行。

标签: mysql wordpress debian


【解决方案1】:

您是在 mysql 中运行该命令,但该命令实际上是要直接从终端运行。

mysqladmin -u root password mypassword

如果您已经在终端中的 mysql 中,请输入 exit 然后输入您的 mysqladmin 命令。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 2015-07-10
    • 2020-08-09
    • 2018-06-02
    • 1970-01-01
    相关资源
    最近更新 更多