php Windows 上的 Magento 安装在 xampp 上显示数据库连接错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4644768/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:49:53  来源:igfitidea点击:

Magento installation on windows shows Database connection error on xampp?

phpmagentoe-commercemagento-1.4

提问by svk

I am using the xampp Version 1.6.4 with PHP Version 5.2.4 and I am trying to Install the Magento latest version on xampp.I got the error in the configuration page.That is, it shows the 'Database connection error.'.
Fields I filled up in the Page:

我正在使用 xampp 版本 1.6.4 和 PHP 版本 5.2.4,我正在尝试在 xampp 上安装 Magento 最新版本。我在配置页面中遇到错误。也就是说,它显示了“数据库连接错误”。.
我在页面中填写的字段:

Database Connection

数据库连接

  1. Host ----- localhost
  2. Database Name---- Magento(already created in phpMyadmin)
  3. User Name ----- root
  4. Password ----- blank
  1. 主机 ----- 本地主机
  2. 数据库名称---- Magento(已在phpMyadmin中创建)
  3. 用户名 ----- root
  4. 密码 ----- 空白

Web access options

网络访问选项

  1. Base URL ------ http://127.0.0.1/magento/

  2. Admin Path ------ admin

  3. Enable Charts ---- Checked

  4. Skip Base URL Validation Before the Next Step --Checked

  5. Use Web Server (Apache) Rewrites --- Unchecked

  6. Use Secure URLs (SSL) ---- Unchecked

  1. 基本 URL ------ http://127.0.0.1/magento/

  2. 管理员路径------管理员

  3. 启用图表----勾选

  4. 在下一步之前跳过基本 URL 验证 --Checked

  5. 使用 Web 服务器 (Apache) 重写 --- 未选中

  6. 使用安全 URL (SSL) ---- 未选中

Session Storage Options

会话存储选项

11.Save Session Data In -- File system

11.Save Session Data In -- 文件系统

I already created the Magento database in the phpMyadmin.But when I click continue it displays error.I dont know why?Please help me in this.

我已经在 phpMyadmin 中创建了 Magento 数据库。但是当我点击继续时,它显示错误。我不知道为什么?请帮我解决这个问题。

Update:phpMyadminConfiguration

更新:phpMyadminConfiguration

$cfg['PmaAbsoluteUri'] = '';
$cfg['PmaNoRelation_DisableWarning']  = FALSE;
$cfg['blowfish_secret'] = 'xampp';
$i = 0;
$i++;
$cfg['Servers'][$i]['host']          = 'localhost'; 
$cfg['Servers'][$i]['port']          = '';         
$cfg['Servers'][$i]['socket']        = '';         
$cfg['Servers'][$i]['ssl']           = false;       
$cfg['Servers'][$i]['connect_type']  = 'tcp';       
$cfg['Servers'][$i]['extension']     = 'mysql';     
$cfg['Servers'][$i]['compress']      = FALSE;       
$cfg['Servers'][$i]['controluser']   = '';          
$cfg['Servers'][$i]['controlpass']   = '';          // access to the "mysql/user"
$cfg['Servers'][$i]['auth_type']     = 'config';    
$cfg['Servers'][$i]['user']          = 'root';      
$cfg['Servers'][$i]['password']      = '';     
$cfg['Servers'][$i]['SignonSession'] = '';         
$cfg['Servers'][$i]['SignonURL']     = '';          
$cfg['Servers'][$i]['LogoutURL']     = '';          
$cfg['Servers'][$i]['nopassword']    = FALSE;       
$cfg['Servers'][$i]['only_db']       = '';          
$cfg['Servers'][$i]['hide_db']       = '';         
$cfg['Servers'][$i]['verbose']       = '';          
$cfg['Servers'][$i]['pmadb']         = '';          

回答by Adam Nicholson

Go to users within phpMyAdmin.
Make sure the hostfor the user you're entering in Magento is set to localhostand not %(any).

转到 phpMyAdmin 中的用户。
确保host您在 Magento 中输入的用户的 设置为localhost并且不是%(任何)。

回答by BrianVPS

This is a pretty old question but I came across it recently and I hope this answer helps someone else. My issue came down to an old version of Magento on top of a new WAMP installation. Since MySQL 5.6.1, the have_innodbvariable has been removed. However, the Magento installer checks for that variable and throws an error if it doesn't find it. If you actually check the exception log you'll see an error that the database server does not support InnoDB. Yet in the catchhandler it only logs that exception and throws a generic "Database connection error" message.

这是一个很老的问题,但我最近遇到了它,我希望这个答案对其他人有所帮助。我的问题归结为在新的 WAMP 安装之上安装了旧版本的 Magento。从 MySQL 5.6.1 开始,have_innodb变量已被删除。但是,Magento 安装程序会检查该变量并在找不到时抛出错误。如果您实际检查异常日志,您将看到数据库服务器不支持 InnoDB 的错误。然而,在catch处理程序中,它只记录该异常并抛出通用的“数据库连接错误”消息。

The simplest fix, if you're sure your DB supports InnoDB, is to simply edit app\code\core\Mage\Install\Model\Installer\Db.php, find the checkDatabasemethod, and comment out the portion at the end of the tryblock that checks for have_innodb. Normally, I would not advocate editing core files, but this is only to get the installer working, so I'd say it's safe enough.

如果您确定您的数据库支持 InnoDB,最简单的解决方法是简单地编辑app\code\core\Mage\Install\Model\Installer\Db.php,找到checkDatabase方法,然后注释掉try检查have_innodb的块末尾的部分。通常,我不提倡编辑核心文件,但这只是为了让安装程序正常工作,所以我会说它足够安全。

Hope that helps anyone else in a similar situation.

希望能帮助其他处于类似情况的人。

回答by Thanu

I had the same problem, but after using host:port it worked perfectly. In my case its 127.0.0.1:3306

我遇到了同样的问题,但是在使用 host:port 后它运行良好。就我而言,它的 127.0.0.1:3306

回答by eshita gupta

Steps to solve your problem.

解决您的问题的步骤。

  1. Type localhostand enter
  2. Select englishoption
  3. localhost/xampp/index.phppage will come
  4. Left sidebar have securitytab, click on that
  5. localhost/security/index.phppage will come
  6. Set your username rootand password (as u want)
  7. Go for installation process and fill \
  1. 类型localhostenter
  2. 选择english选项
  3. localhost/xampp/index.php页面会来
  4. 左侧边栏有security标签,点击那个
  5. localhost/security/index.php页面会来
  6. 设置您的用户名root和密码(如您所愿)
  7. 去安装过程并填写\

Database Connection:

数据库连接:

Host ----- localhost
Database Name---- Magento(already created in phpMyadmin)
User Name ----- root
Password ----- you have set above

That's all perfect.

这一切都很完美。

回答by Albie Linechar

I think for magneto database you need to access to the local host area but let's say we have a site like http://yoursite.comand if we substitute anything at the place of comthen what will be the procedures? I have multiple sites and going to set this but I do not want to get errors.

我认为对于磁数据库,您需要访问本地主机区域,但假设我们有一个类似的站点http://yoursite.com,如果我们在该位置替换任何内容,com那么程序将是什么?我有多个站点并打算设置它,但我不想出错。

回答by Abraham Brookes

You need to provide an all privileges account witha password on your magento database. Once you click continue Magento will populate the database with a whole bunch of tables. It can take a few minutes depending on your connection or your PC (for local installations).

您需要在您的 magento 数据库上提供一个带有密码的所有权限帐户。单击继续后,Magento 将用一大堆表填充数据库。这可能需要几分钟时间,具体取决于您的连接或您的 PC(对于本地安装)。

回答by Andrey Korolyov

Try to change at Database connection settings host to 127.0.0.1

尝试将数据库连接设置主机更改为 127.0.0.1

回答by Alan

I had a similar issue. It appears it is related to a DNS issue in that Magento is looking for a valid type URL of the form http://xxxxxx.xxxwhere x is whatever name you create. Dont use a .com, .net etc..create some random one .ecs for example. You can't use 127.0.0.1 as the URL or localhost for Magento (at least that was my experience using XAMPPLITE.

我有一个类似的问题。它似乎与 DNS 问题有关,因为 Magento 正在寻找形式为http://xxxxxx.xxx的有效类型 URL, 其中 x 是您创建的任何名称。不要使用 .com、.net 等。例如,创建一些随机的 .ecs。您不能使用 127.0.0.1 作为 Magento 的 URL 或本地主机(至少这是我使用 XAMPPLITE 的经验。

I downloaded HostXpert (free) and assigned a dummy URL like demo.ecs to 127.0.0.1 and then did the Magento install to demo.ecs

我下载了 HostXpert(免费)并将一个像 demo.ecs 这样的虚拟 URL 分配给 127.0.0.1,然后将 Magento 安装到 demo.ecs

Before you do the install, verify that your localhost demo.ecs works when you load it into your browser.

在安装之前,请验证您的 localhost demo.ecs 在您将其加载到浏览器中时是否正常工作。

Hope that helps.

希望有帮助。

回答by Josue

It seems you are using XAMPP for local development. In that case, you may want to also checkout BitNami Magento. It is very similar to XAMPP in that it is free, multiplatform and self-contained, but it comes with Magento preinstalled by default.

您似乎正在使用 XAMPP 进行本地开发。在这种情况下,您可能还想签出BitNami Magento。它与 XAMPP 非常相似,因为它是免费的、多平台的和自包含的,但它默认预装了 Magento。

回答by Sabe Barker

For me this was a permissions problem.

对我来说,这是一个权限问题。

I had given the user grant all permissions from the commandline but on rechecking through phpMyAdmin (because of this error) I noticed that the user did not have the permissions I had set.

我已从命令行授予用户所有权限,但在通过 phpMyAdmin 重新检查时(由于此错误),我注意到该用户没有我设置的权限。

Once I corrected this it worked.

一旦我纠正了这个问题,它就起作用了。

The users section is shown in the image below:

用户部分如下图所示:

phpMyAdmin Users Section

phpMyAdmin 用户部分