【发布时间】: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