database 无法选择数据库 - Wordpress

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

Can't select database - Wordpress

databasewordpresswamp

提问by user3164083

When I download a new wordpress from wordpress.org and then paste it into my www folder of WAMP, then create a new database in phpmyadmin, then go to localhost and click the wordpress site, it asks to create the config file, and enter the database details, and i do that correctly, but when I click submit, it says "Can't select database".

当我从 wordpress.org 下载一个新的 wordpress,然后将其粘贴到 WAMP 的 www 文件夹中,然后在 phpmyadmin 中创建一个新数据库,然后转到 localhost 并单击 wordpress 站点,它要求创建配置文件,然后输入数据库详细信息,我这样做是正确的,但是当我单击提交时,它显示“无法选择数据库”。

Any Idea why this is?

知道这是为什么吗?

I already have a local wordpress site that started saying error connecting to database. The config settings are all correct so i tried to download a fresh wordpress site and use it and I cannot even set up a fresh one. I have never encountered a fresh wordpress site not working like this before.

我已经有一个本地 wordpress 站点,它开始说连接到数据库时出错。配置设置都是正确的,所以我尝试下载一个新的 wordpress 站点并使用它,但我什至无法设置一个新站点。我从来没有遇到过一个新的 wordpress 网站不能像这样工作。

I did a msqldump of my old site so that my boss could put it on his server. Not sure if that is relevant.

我对我的旧网站做了一个 msqldump,这样我的老板就可以把它放在他的服务器上。不确定这是否相关。

Cheers.

干杯。

回答by Vladimir Marton

For anyone who's still looking for solutions to this problem - please, check again your wp-config.php database credentials again. I had the same problem today and tried to over-complicate the matter by searching for advanced solutions, while I had a space in my DB_NAME field (was supposed to be 'wpdb' and was ' wpdb').

对于仍在寻找此问题解决方案的任何人 - 请再次检查您的 wp-config.php 数据库凭据。我今天遇到了同样的问题,并试图通过搜索高级解决方案来使问题变得过于复杂,而我的 DB_NAME 字段中有一个空格(应该是“wpdb”而是“wpdb”)。

This space completely messed up my connection, I was even close to reinstalling the whole thing and losing all data.

这个空间完全弄乱了我的连接,我什至差点重新安装整个东西并丢失所有数据。

回答by Aakash

If using LAMP -

如果使用 LAMP -

Make sure that all privileges are granted for that database to the created mysql user. Under your MYSQL shell use the below

确保已将该数据库的所有权限授予创建的 mysql 用户。在您的 MYSQL shell 下使用以下命令

GRANT ALL PRIVILEGES ON database_name.* TO database_user@localhost IDENTIFIED BY 'user_password';

Where,

在哪里,

database_name = your database name as per wp-config.php

database_name = 根据 wp-config.php 的数据库名称

database_user = your user name as per wp-config.php

database_user = 您的用户名,按照 wp-config.php

userpassword = your user password as per wp-config.php

userpassword = 您的用户密码,根据 wp-config.php

回答by Rajwant

Please don't overcomplicate.

请不要过于复杂。

In the "Database Host" field add "localhost: e.g. in my case "localhost:3308" solved the problem.

在“数据库主机”字段中添加“localhost:例如在我的例子中”localhost:3308“解决了这个问题。

回答by XIMRX

It sounds like either you have not created a database or your wp-config file is not set up correctly. Have you edited wp-config.php file of wordpress and provided correct database name and user credentials. See Famous 5 minute installationof wordpress for details.

听起来您还没有创建数据库,或者您的 wp-config 文件设置不正确。您是否编辑过 wordpress 的 wp-config.php 文件并提供了正确的数据库名称和用户凭据。有关详细信息,请参阅著名的 5 分钟安装wordpress。

回答by user3164083

It took me way too long to discover that my msql databases were not working on any other websites either. I reinstalled Wamp Server and it worked.

我花了很长时间才发现我的 msql 数据库也不能在任何其他网站上运行。我重新安装了 Wamp Server,它工作正常。

回答by Daniel

Verify the wp-config.php file. I had the same error and the problem was related with the quotes: ‘root' vs 'root'

验证 wp-config.php 文件。我有同样的错误,问题与引号有关:'root' vs 'root'

edit: the correct one is single quote

编辑:正确的是单引号

'

回答by Shubham Agrawal

By default

默认情况下

username: root

用户名

password: leave it blank

密码:留空

database host: localhost

数据库主机本地主机

table_prefix: wp_

表前缀wp_

回答by simhumileco

For me, the solution was givingwp_userall permissions on thewp_dbdatabase.

对我来说,解决方案是wp_user授予对数据库的所有权限wp_db

I achieved this using the command line interpreter (CLI):

我使用命令行解释器 (CLI) 实现了这一点:

$ mysql -uroot -p
MariaDB [(none)]> GRANT ALL ON `wp_db`.* TO `wp_user`@`localhost` IDENTIFIED BY 'pass';
MariaDB [(none)]> exit;

After these operations, I restarted the database:

在这些操作之后,我重新启动了数据库:

$ systemctl restart mysql

Of course, the database name(wp_db), username(wp_user), and password of the user(pass) can be different.

当然,数据库名称wp_db)、用户名wp_user)和用户的密码pass)可以不同。

回答by Leo

my problem was that when I granted permissions to the DB user the host did not match what was in the wp_config.php

我的问题是,当我向数据库用户授予权限时,主机与 wp_config.php 中的内容不匹配

/** MySQL hostname */
define('DB_HOST', 'localhost:3306');

I was granting rights with

我正在授予权利

GRANT ALL ON databaseName.* TO 'UserName'@'127.0.0.1';

This gave me access when I was connected to the local host through ssh but It did not match wp_config.php. so I had to Grant like this then it all worked.

当我通过 ssh 连接到本地主机时,这给了我访问权限,但它与 wp_config.php 不匹配。所以我不得不像这样授予,然后一切都奏效了。

GRANT ALL ON databaseName.* TO 'UserName'@'localhost';

回答by Ankita Shinde

For Mariadb hostname should be localhost:3306 and for MySQL localhost:3308.this fixed my error.

对于 Mariadb 主机名应该是 localhost:3306,对于 MySQL localhost:3308.this 修复了我的错误。