Can't select database - Wordpress
Asked Answered
A

16

8

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".

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.

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

Cheers.

Ares answered 17/7, 2014 at 11:12 Comment(3)
check your config details are correctNord
Is the wordpress database still available? Can you look at it's content without using wordpress (like using phpmyadmin)?Mishmash
check your DB and DB user role permissionsSandfly
O
15

Please don't overcomplicate.

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

Ochre answered 14/5, 2020 at 14:15 Comment(0)
F
4

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').

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

Favrot answered 3/5, 2017 at 13:22 Comment(0)
C
2

If using LAMP -

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

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_user = your user name as per wp-config.php

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

Crossbred answered 27/9, 2017 at 15:31 Comment(2)
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 'IDENTIFIED BY 'user_password'' at line 1Finnougrian
That one liner is described as deprecated: #31112347Finnougrian
E
1

By default

username : root

password : leave it blank

database host : localhost

table_prefix : wp_

Encrust answered 4/8, 2018 at 14:42 Comment(0)
A
1

please create your database with name 'wordpress' before installing wordpress

Anthelmintic answered 2/3, 2020 at 18:53 Comment(0)
B
0

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 installation of wordpress for details.

Bruton answered 17/7, 2014 at 11:15 Comment(6)
Yes thanks. On the last step of that installation (going to the url) it says "Error establishing a database connection". Is it connected to me cancelling my subscription?Ares
Can you show your wp-config.php file code. (removing password)Bruton
First make sure database name is the_commons. Secondly root by default has empty password so make sure in wp-config.php your password is set like: define('DB_PASSWORD', '');Bruton
Just discovered that none of my databases work on any of my web sites any more. I have WAMP all services running including mysqlAres
Before messing with databases create new user with all privileges and use it.Bruton
Have you recently installed something that comes with its own MySQL. In other words are you running two MySQL Server?Keshiakesia
A
0

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.

Ares answered 17/7, 2014 at 12:50 Comment(0)
F
0

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

edit: the correct one is single quote

'
Flickertail answered 14/1, 2017 at 12:46 Comment(0)
U
0

For me, the solution was giving wp_user all permissions on the wp_db database.

I achieved this using the command line interpreter (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.

Uracil answered 2/2, 2019 at 18:39 Comment(0)
M
0

my problem was that when I granted permissions to the DB user the host did not match what was in the 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.

GRANT ALL ON databaseName.* TO 'UserName'@'localhost';
Mirador answered 23/4, 2019 at 18:23 Comment(1)
For MariaDB yes it's 3306 and 3308 for MySQL.Neaten
B
0

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

Batting answered 14/12, 2019 at 6:51 Comment(0)
C
0

I had this issue when trying to transfer databases between WAMP server installations.

I tried opening PhpMyAdmin on new PC, then got the port of MySql server (:3308) and added this port into DB_HOST ('localhost:3308'). This worked for me.

Chemo answered 14/12, 2019 at 17:35 Comment(0)
L
0

You may need to create the database yourself. Visit http://localhost:8888/phpMyAdmin5 create a new database with the name you prefer. Don't add any table names, just use the name you choose for the database in the WordPress setup

Listed answered 31/7, 2021 at 12:15 Comment(0)
S
0

If anyone is still having this problem. The form fields auto-populate with placeholders. You have to type over the placeholder information to enter the data. Took me over an hour to figure this out.

Standford answered 13/6, 2023 at 2:37 Comment(0)
O
0

After doing an Acronis profile restore I encountered this same issue and I spent a long time trying to figure out what the issue could be I found that even though my user was appearing in the list of users it did not have any privileges set up.

I was able to check the privileges by going into phpMyAdmin and checking privileges on the db.

I was using cPanel and so I did the following:

  • Under the databases header I selected 'MySQL Databases'
  • Then scroll down to the heading 'Add User To Database'
  • Select the user that is in your wp-config file
  • Click 'Add User'
  • Give them the SELECT Privilege
  • Click 'Add/Edit User'
Outherod answered 18/8, 2023 at 18:17 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewMeave
A
-1

The solution is, that you are not entering the database name inside the form. The placeholder is so similar, that you misunderstood the value but actually, there is not any value as "wordpress" Just re-enter, so you will get what I am trying to say.

Aube answered 23/6 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.