7

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.

user3164083
  • 1,053
  • 6
  • 18
  • 35

15 Answers15

12

Please don't overcomplicate.

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

Rajwant
  • 121
  • 1
  • 2
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.

Vladimir Marton
  • 569
  • 4
  • 31
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

Aakash
  • 21
  • 1
  • `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 1` – Flair Nov 19 '18 at 21:59
  • That one liner is described as deprecated: https://stackoverflow.com/questions/31111847/identified-by-password-in-mysql – Flair Nov 19 '18 at 22:19
1

By default

username : root

password : leave it blank

database host : localhost

table_prefix : wp_

Shubham Agrawal
  • 1,252
  • 12
  • 29
1

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

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.

XIMRX
  • 2,130
  • 3
  • 29
  • 60
  • 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? – user3164083 Jul 17 '14 at 11:21
  • 1
    Can you show your wp-config.php file code. (removing password) – XIMRX Jul 17 '14 at 11:24
  • 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', '');` – XIMRX Jul 17 '14 at 11:29
  • Just discovered that none of my databases work on any of my web sites any more. I have WAMP all services running including mysql – user3164083 Jul 17 '14 at 11:37
  • Before messing with databases create new user with all privileges and use it. – XIMRX Jul 17 '14 at 11:51
  • Have you recently installed something that comes with its own MySQL. In other words are you running two MySQL Server? – RiggsFolly Jul 17 '14 at 12:26
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.

user3164083
  • 1,053
  • 6
  • 18
  • 35
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

'
Daniel
  • 1
  • 3
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.

simhumileco
  • 31,877
  • 16
  • 137
  • 115
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';
Leo
  • 1,495
  • 23
  • 41
0

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

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.

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
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

Libu Mathew
  • 2,976
  • 23
  • 30
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.

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'
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34863958) – Joe Niland Aug 22 '23 at 10:46