new installation on Windows Server
-
The Windows server I am using has MySQL installed on it by Platform Installer, so now I am trying to use a database that I created in MySQL to be the database for a fresh WordPress installation but whenever I go to the site URL and enter the database info and tell the page to use ‘localhost’ as the host, I get the error “Error establishing a database connection” Anyone know why I am getting that error?
- This topic was modified 5 years, 5 months ago by mace19.
-
Using
localhost
as DB_HOST usually causes problems on Windows systems. Try using127.0.0.1
instead. If that doesn’t help, then access mysql from the command line and issue the following command:STATUS;
Find the line that displays the connection type. If it is a TCP/IP connection, find the line that displays the TCP port, and then append that port number to the DB_HOST definition in wp-config.php as follows:
127.0.0.1:3306
. (The port will probably be 3306, which is why I used it.) If the TCP/IP connection shows something other than 127.0.0.1 or localhost, use that IP address instead.If the connection type states that you are using a named pipe, then you have problems. Modern versions of PHP do not seem to work correctly with Windows named pipes. You’ll need to either change the MySQL configuration to use a TCP/IP connection, or install your own version of MySQL that has the proper connection type.
Thanks for the response, but I tried localhost, localhost:3306, 127.0.0.1 and 127.0.0.1:3306 but I am still getting the same error.
`
H:\>”C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe” -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 8.0.16 MySQL Community Server – GPLCopyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> STATUS;
————–
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.16 for Win64 on x
86_64 (MySQL Community Server – GPL)Connection id: 49
Current database:
Current user: root@localhost
SSL: Cipher in use is XXXXXXXXXXXXXXX
Using delimiter: ;
Server version: 8.0.16 MySQL Community Server – GPL
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 3 hours 30 min 25 secThreads: 2 Questions: 24 Slow queries: 0 Opens: 164 Flush tables: 3 Open ta
bles: 68 Queries per second avg: 0.001
————–
`
and a detail that might be relevant: when I edit the config file directly instead of use that web interface to create the file I still get the ‘Error establishing a database connection’ BUT with no explanation of the error after.
The PHP native MySQL drivers have problems connecting to MySQL 8. Go to your PHP directory and type the following command:
php -m
Make sure that both
mysqli
andmysqlnd
are listed. If one or both are missing, then check your php.ini file to make sure both modules are being loaded. If they are missing from php.ini, then add them, restart Apache/PHP. and runphp -m
again. If they are still not being loaded, then disable SSL and the login encryption plugin in MySQL 8, restart MySQL and Apache/PHP. and runphp -m
again. If they are still not being loaded, then your only recourse is to revert back to MySQL 5.7.@diondesigns ok I did
php -m
and it looks like the modules listed bothmysqli
andmysqlnd
. Do I need to run them with administrative privs somehow?Please add the following line to the
[mysqld]
section of the MySQL configuration file, and then restart MySQL:default_authentication_plugin=mysql_native_password
While you are looking at the MySQL configuration file, if you find a line similar to this one:
require_secure_transport = 1
either comment it out or delete it.
PHP is incompatible with the default authentication plugin in MySQL 8, and the PHP native MySQL driver has problems if SSL is required for all connections.
damn, I really thought that was going to work!
ok I added the
default_authentication_plugin=mysql_native_password
under[mysqld]
to my.ini and saved it. (I had to run notepad as administrator to save the file into the same place because it was overwriting the old version of that file)There was no line in the file
require_secure_transport = 1
.I restarted the
MYSQL80
service and then tried to create the config file with the browser and then a file again:
Database Name: dbname
user: root
password:
Host: 127.0.0.1:3306
Prefix: wp_
error. I did notice that in the
STATUS
output above the charset for the server and the client is different… is that something that may cause this problem?- This reply was modified 5 years, 5 months ago by mace19.
One final check…is port 3306 open on your firewall?
hmm, the Network Admins here say that yes it is, but is there a way I can check that the
mysql
processes are allowed to connect?I have a feeling this problem is related to the firewall, but I don’t know how to check. The Windows Firewall is disabled and firewalling is handled by an outside service.
Thanks again for your help, any other ideas you have would be much appreciated.
- This reply was modified 5 years, 5 months ago by mace19.
If you want to check whether 127.0.0.1:3306 is working, first make sure the Telnet client is installed. Go to Control Panel, Programs and Features, Turn Windows features on or off, and tick the box next to Telnet client.
Then go to the command line and type:
telnet 127.0.0.1 3306
You should see the MySQL version number, the auth plugin name, and some gibberish. Press Enter a few times to exit out of telnet. If you cannot connect, then port 3306 and/or 127.0.0.1 are being blocked. I’d guess the issue was port 3306, but I’ve seen some pretty stupid network setups so I won’t rule out localhost being blocked.
ok that worked, I was able to connect, but I also tried installing wordpress through Windows Web Platform Installer but the installation failed because it was unable to connect to MySQL, even though I am using the credentials that allow me to log in from the command prompt. Maybe I didn’t set up MySQL correctly?
mysql> SHOW GRANTS FOR root@localhost;
+——————————————————————————-
——————————————————————————–
——————————————————————————–
——————————————————————————–
——————————————————————————–
———————————+
| Grants for root@localhost|
+——————————————————————————-
——————————————————————————–
——————————————————————————–
——————————————————————————–
——————————————————————————–
———————————+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS,
FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW
VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESP
ACE, CREATE ROLE, DROP ROLE ON *.* TOroot
@localhost
WITH GRANT OPTION
|
| GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_A
DMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VA
RIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,R
OLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_US
ER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `roo
t@
localhost` WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ONdatabasename
.* TOroot
@localhost
|
| GRANT PROXY ON ”@” TO ‘root’@’localhost’ WITH GRANT OPTION|
+——————————————————————————-
——————————————————————————–
——————————————————————————–
——————————————————————————–
——————————————————————————–
———————————+
4 rows in set (0.00 sec)mysql>
(thats how the spacing is, I didn’t do that)
- This reply was modified 5 years, 5 months ago by mace19.
At this point, I think your best course of action is to delete MySQL 8.0, and install MySQL 5.7 in its place.
I also suggest asking this question on either https://wordpress.stackexchange.com or https://dba.stackexchange.com.
Oh ok thanks, I do not have access to that server this weekend, but on Monday morning I will do both of those things!
Maybe I am misremembering but I did not see MySQL 5.7 as an option on Windows Web Platform Installer, so where would I install that from?got it to work, thanks for everything! I uninstalled all old MySQL instances and used the Windows Web Platform Installer version.
- The topic ‘new installation on Windows Server’ is closed to new replies.