【问题标题】:cannot access phpmyadmin database in xampp server无法访问 xampp 服务器中的 phpmyadmin 数据库
【发布时间】:2014-07-08 06:12:24
【问题描述】:

我在我的系统中安装了xampp。然后在记事本中打开httpd.conf文件和modified server name and server admin,即;我将 localhost 更改为我的系统 IP 地址。在 config.inc.php 中,我将服务器 ip '127.0.0.1' 更改为我的系统 ip 地址。然后我打开 XAMPP 控制面板,安装 Apache 和 MySql 并启动它。我单击 Mysql 按钮前面的 Admin 按钮打开数据库。它显示'Host cannot connect to mysql server'。然后我打开了XAMPP for Windows command prompt。我有错误

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 'mysql
 -u root' at line 1

我是否缺少任何不允许连接到数据库的配置设置?我已经检查了文档根目录。路径是正确的。我没有找到我出错的地方。

Setting environment for using XAMPP for Windows.
rakshitha@OCEANMLRLP02 c:\xampp
# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)

mysql> mysql -u root;
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 'mysql
 -u root' at line 1

【问题讨论】:

  • mysql -u root 是一个以root 用户身份连接到 mysql 服务器的 shell 命令。由于您已经在 mysql 监视器内部,它需要一个查询,而不是一个 shell 命令,所以这就是为什么会出现错误;它是一个 shell 命令,而不是查询。
  • XAMPP 几乎是开箱即用的所有这些东西的工作实例。您正在对应该“正常工作”的事情进行大量修补。例如,尝试回滚您对config.inc.php 的更改;在这种情况下,我相信 XAMPP 工具包会阻止来自非本地连接的 MySQL 连接,并且当您更改要连接的 IP 地址时,您会影响 PHP 与 MySQL 的通信方式(使其成为来自 127.0.0 以外 IP 地址的网络连接。 0.1)。可能您的用户仅设置为通过 localhost 或 127.0.0.1 进行连接。

标签: mysql phpmyadmin xampp


【解决方案1】:

问题是你已经登录了:) “mysql -u root”是一个登录mysql服务器的命令。 “mysql>”提示表示你已经进入,你应该在这里使用 MySQL 命令,正如你在“mysql> show databases;”行中所做的那样。

【讨论】:

  • 好的。我不知道这个。我是新来的。我可以访问数据库。我看到了地址,它是 localhost:8082/phpmyadmin。但是,我想使用我的系统 IP 地址而不是 localhost 进行连接,以便我可以远程访问该数据库。我不应该做哪些配置设置来实现这一点?
  • 您必须有可能建立到您的服务器的 ssh 连接,然后您只需使用“mysql -u -p”。对于 ssh 连接,请使用 linux 终端或 windows 上的 putty。
  • 我只是想澄清我的疑问。 config.inc.php 中的行,$cfg['Servers'][$i]['host'] = '127.0.0.1';表示“phpmyadmin 数据库应在 IP 地址为“127.0.0.1”的服务器中运行。
  • 我认为确实如此。记住一件事:不要将 localhost/127.0.0.1 更改为其他地址。这是本地机器的定义。如果您想指出其他地址/域,您应该通过在路由器和/或 dns 上配置路由(即更改主机定义)来做到这一点。
  • 好的。我会试试看。
猜你喜欢
  • 2014-01-16
  • 2013-03-17
  • 2016-01-22
  • 2020-12-05
  • 2014-07-23
  • 2014-03-20
  • 2012-10-10
  • 2013-05-12
  • 2019-07-01
相关资源
最近更新 更多