如何通过 XAMPP 使用 MySQL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17823189/
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
How do I use MySQL through XAMPP?
提问by JustBlossom
I installed XAMPP v3.2.1 because I wanted to learn how to create database in MySQL and learn more about TOMCAT. However, I am a little confused about what to do now. I have read many blogs and the documentation on this page http://dev.mysql.com/doc/refman/5.0/en/creating-database.html.
我安装 XAMPP v3.2.1 是因为我想学习如何在 MySQL 中创建数据库并了解更多关于 TOMCAT 的知识。但是,我对现在要做什么感到有些困惑。我已经阅读了该页面http://dev.mysql.com/doc/refman/5.0/en/creating-database.html上的许多博客和文档。
While following the directions I found that: I can't access my local host.
在按照指示进行操作时,我发现:我无法访问我的本地主机。
Attempted Solution: I shut down skype because I read that might be an issue. I don't have any older versions of XAMPP on my computer and I don't believe I am connected to any other servers. So, I don't have permission to do anything.
尝试的解决方案:我关闭了 Skype,因为我读到这可能是一个问题。我的计算机上没有任何旧版本的 XAMPP,而且我认为我没有连接到任何其他服务器。所以,我没有权限做任何事情。
OR
或者
Am I trying to access mysql through the wrong command prompt? I am trying to use MySQL from the XAMPP shell. I am not sure why I cannot get everything working. Am I going about this the wrong way?
我是否试图通过错误的命令提示符访问 mysql?我正在尝试从 XAMPP shell 使用 MySQL。我不知道为什么我不能让一切正常。我会以错误的方式解决这个问题吗?
Thanks for any help
谢谢你的帮助
回答by Hidden
XAMPP only offers MySQL (Database Server) & Apache (Webserver) in one setup and you can manage them with the xampp starter.
XAMPP 仅在一种设置中提供 MySQL(数据库服务器)和 Apache(Web 服务器),您可以使用 xampp starter 管理它们。
After the successful installation navigate to your xampp folder and execute the xampp-control.exe
安装成功后导航到您的 xampp 文件夹并执行 xampp-control.exe
Press the start Button at the mysql row.
在 mysql 行按下开始按钮。
Now you've successfully started mysql. Now there are 2 different ways to administrate your mysql server and its databases.
现在你已经成功启动了 mysql。现在有两种不同的方法来管理您的 mysql 服务器及其数据库。
But at first you have to set/change the MySQL Root password. Start the Apache server and type localhost
or 127.0.0.1
in your browser's address bar. If you haven't deleted anything from the htdocs folder the xampp status page appears. Navigate to security settings and change your mysql root password.
但首先您必须设置/更改 MySQL Root 密码。启动 Apache 服务器并在浏览器的地址栏中键入localhost
或127.0.0.1
。如果您尚未从 htdocs 文件夹中删除任何内容,则会出现 xampp 状态页面。导航到安全设置并更改您的 mysql 根密码。
Now, you can browse to your phpmyadmin under http://localhost/phpmyadmin
or download a windows mysql client for example navicat lite or mysql workbench. Install it and log in to your mysql server with your new root password.
现在,您可以浏览到您的 phpmyadminhttp://localhost/phpmyadmin
或下载 Windows mysql 客户端,例如 navicat lite 或 mysql workbench。安装它并使用新的 root 密码登录到您的 mysql 服务器。
回答by Ramlal S
XAMPP Apache + MariaDB + PHP + Perl (X -any OS)
XAMPP Apache + MariaDB + PHP + Perl(X-任何操作系统)
- After successful installation execute xampp-control.exe in XAMPP folder
Open browser and in url type
localhost
or127.0.0.1
- then you are welcomed with dashboard
- 安装成功后在 XAMPP 文件夹中执行 xampp-control.exe
打开浏览器并输入 url 类型
localhost
或127.0.0.1
- 然后你会受到仪表板的欢迎
By default your port is listing with 80.If you want you can change it to your desired port number in httpd.conffile.(If port 80 is already using with other app then you have to change it).
默认情况下,您的端口以80列出。如果您愿意,可以在httpd.conf文件中将其更改为所需的端口号。(如果端口 80 已与其他应用程序一起使用,则必须更改它)。
For example you changed port number 80 to 8090 then you can run as 'localhost:8090' or '127.0.0.1:8090'
例如,您将端口号 80 更改为 8090,然后您可以作为 'localhost:8090' 或 '127.0.0.1:8090' 运行
回答by L Santosh Kumar
Changing XAMPP Default Port: If you want to get XAMPP up and running, you should consider changing the port from the default 80 to say 7777.
更改 XAMPP 默认端口:如果您想让 XAMPP 启动并运行,您应该考虑将端口从默认 80 更改为 7777。
In the XAMPP Control Panel, click on the Apache – Config button which is located next to the ‘Logs' button.
Select ‘Apache (httpd.conf)' from the drop down. (Notepad should open)
Do Ctrl+F to find '80' and change line Listen 80 to Listen 7777
Find again and change line ServerName localhost:80 to ServerName localhost:7777
Save and re-start Apache. It should be running by now.
在 XAMPP 控制面板中,单击位于“日志”按钮旁边的 Apache – 配置按钮。
从下拉列表中选择“Apache (httpd.conf)”。(记事本应该打开)
做 Ctrl+F 找到 '80' 并将行 Listen 80 更改为 Listen 7777
再次查找并将行 ServerName localhost:80 更改为 ServerName localhost:7777
保存并重新启动 Apache。它现在应该正在运行。
The only demerit to this technique is, you have to explicitly include the port number in the localhost url. Rather than http://localhost
it becomes http://localhost:7777
.
这种技术的唯一缺点是,您必须在 localhost url 中明确包含端口号。而不是http://localhost
它变成http://localhost:7777
。
回答by ravi ranjan
<?php
if(!@mysql_connect('127.0.0.1', 'root', '*your default password*'))
{
echo "mysql not connected ".mysql_error();
exit;
}
echo 'great work';
?>
if no error then you will get greatwork as output.
如果没有错误,那么您将获得伟大的作品作为输出。
Try it saved my life XD XD
试试它救了我的命 XD XD