I've got everything to work with WP-CLI on Windows running XAMPP. Or so I thought. When I try to execute the following command:
wp rewrite structure '/%postname%/'
I get the following error:
Error: Error establishing a database connection. This either means that the username and password information in your wp-config.php file is incorrect or we canÔÇÖt contact the database server at localhost. This could mean your hostÔÇÖs database server is down.
I've read that the PHP used needs to be correct (a usual explanation for this problem). Running wp --info yields the following results.
$ wp --info
PHP binary: C:\xampp\xampp-5.6.24\php\php.exe
PHP version: 5.6.24
php.ini used: C:\xampp\xampp-5.6.24\php\php.ini
WP-CLI root dir: C:\lib\wp-cli
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.0.0
I think that this looks correct. I can access the db from a browser, use WP normally, and even perform database commands using wp-cli. But for some reason, the rewrite command gives an error (as stated above). The fun thing is that it actually changes the permalink option, but I'm afraid that since it gives an error some other action is not performed correctly.
Changing the credentials in wp-config.php makes me unable to run db commands, so clearly it works at some level.
What might be wrong? I'm pretty clueless here!
The database is set up by using wp-cli and is accessed using the root account.
It turned out to be a bug in wp-cli, which the author is now working on.
Related
I reset my MySQL password using cmd commands from this guide.
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
mysqld
--defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini"
--init-file=C:\\Users\\<username>\\resetMYSQL.txt
resetMYSQL contains a command to change password
ALTER USER 'root'#'localhost' IDENTIFIED BY '<myNewPassword>';
Now, it turned out I have to keep running the mysqld command above to start my server or else I'll get this error. If I run the command again I can flawlessly run my server until I terminate it.
This is the error. It's ECONNREFUSED.
I think my password is already reset, because apart from the command line, I also run ALTER USER in Workbench after I got access to it while the cmd is running.
Btw, before this I can just start my server using Node and Sequelize and didn't have to start server elsewhere or set anything beforehand
I'm not sure what is the problem here, so I don't know which keyword I should look up on Google. I googled the error code, but those cases seems unrelated to mine.
I'd be glad if you can explain me what's going on.
The nodejs error message you showed us, a ECONNREFUSED message with a traceback, shows the your mysql database server program was not running when your nodejs program tried to connect to it. Nodejs reaches out to MySQL via TCP/IP. TCP/IP responds "I don't know any MySQL." Specifically, it responds "ECONNREFUSED on port 3306," meaning "nothing on this machine accepts connections on MySQL's port."
nodejs does not start the mysql software for you. It connects to it and uses it.. MySQL has to be running already for that work.
Ordinarily, software like mysql runs in the form of a operating system service; a background process that runs all the time on the machine to await requests).
And, ordinarily, you don't provide init files to MySQL to do things like change passwords, except just once, if you must, to rescue something broken. In your case it looks like you forgot your MySQL password, so you needed to use an init file to rescue yourself. Once the password is reset, stop using that init file.
Explaining how to make MySQL run as a service on your machine is beyond the scope of a Stack Overflow answer. But the installers for MySQL, on almost every operating system, set it up to run as a service automatically. It's generally useless otherwise.
I have a VPS(VestaCP) with a WordPress installation, and the domain is no longer available. I have set up a temporary URL Using the following instructions: Link
I now have an issue establishing connection.
I've went into the wp-config.php and added the following lines thinking it would solve my issue... But it didn't
// Add these lines to wp-config.php:
define('WP_SITEURL', 'http://*tempurlhere*-com.alpha.*myurl*.com/');
define('WP_HOME', 'http://*tempurlhere*-com.alpha.*myurl*.com/');
Is there something I'm missing? Should I replace the url with the server IP?
The reason for "ERROR ESTABLISHING DATABASE CONNECTION" is the inability of WordPress to reach MySQL or authenticate properly. Check the values of DB_USER,DB_HOST,DB_PASSWORD, and DB_NAME. Fix if needed. Make sure the user exists in MySQL, is allowed to connect from your web host, and has the rights to the database given by DB_NAME. If that does not solve the problem, check if MySQL server up and running. If yes, can it be reached from the web server (e.g. maybe MySQL port is firewalled)?
To check accessibility of the MySQL server from your web host, ssh to the web host, and run:
mysql -u <DB_USER> -p<DB_PASSWORD> -h <DB_HOST> <DB_NAME>
Replacing <var> with the actual values. Note the absence of space between -p and the DB_PASSWORD value.
If the connectivity is confirmed, double-check that you are editing the correct wp-config.php that WordPress is actually using, e.g by adding die("Loading this file now"); at the very top of it, then check if you see that message when you load the site.
If that is indeed the case, verify that the PHP installation includes a functional MySQL driver by writing an small program that will use mysqli_connect() with the relevant credentials and report success or error.
My friend has a mac - we got AMPPS set up so he can run Apache, PHP and MySQL.
We got it up running. I can talk to mysql using phpMyAdmin.
I am running codeigniter - its working fine - but I'm getting an error when it tries connect to the database
Fatal error: Call to undefined function mysqli_init() in
mysqli_driver.php on line 126
I have a feeling that I'm missing the mysql.so extension or module in the Apache install or the PHP install.
How do I install that on a mac, or which config file do I need to modify?
That error indicates that the mysqli.so module is not loaded. Check the results of phpinfo() to see where the configuration file is, and make sure the module's being included properly. Often times there is a separate ini file for each module that's separately installed.
Personally I'd stay away from mysqli and use something higher level like PDO. I'd also recommend installing something maintainable like MacPorts or Homebrew to run Apache/MySQL/PHP instead of a pre-packaged solution.
Doing some local website work to learn Wordpress theme development.
Tried to set up Wordpress through the prompts, also tried it by manually entering information in the wp-config.php file, neither would work. Still cannot connect to the database, the setup-config.php page returns "Error establishing a database connection". I've double, triple, and quadruple checked the login credentials (database name, username, password etc.), they are complete and correct. Deleted wp-config.php and tried again through the web page, same result.
MySQL is definitely running, the Mac System Preferences panel says so, and I can login and run SQL queries at the command line, although I have to do that as root. Should I be running MySQL as root?
This problem exists with Wordpress and also with an instance of phpMyAdmin that I've also installed, so I don't think it's anything to do with the PHP code as such, it smells more like a permissions thing. For what it's worth, I've edited my httpd.conf file to get Wordpress on port 80 and phpMyAdmin on 8081. Apache is serving those sites up as it should and PHP is running, it's just getting either site to connect to the database that's the problem.
System information:
Mac OS X 10.9.5 (Mavericks)
PHP Version 5.4.30
MySQL version:
mysql Ver 14.12 Distrib 5.0.45, for apple-darwin9.2.0 (i686) using EditLine wrapper
In my case it was as simple as changing the DB_HOST so it was using the correct host and port in wp-config.php:
define('DB_HOST', '127.0.01:3306');
I found the solution on this stackoverflow page.
By default, Apache cannot send requests to a remote MySQL server. It should be enabled.
On CentOS 6 the solution is the command:
setsebool httpd_can_network_connect=1
Check your phpinfo(); to see if MySQL extension for php is installed.
I experienced a similar issue and it turned out that the authentication type used by MYSQL was not supported.
To verify this, add
define('WP_DEBUG', true)
in the wp-config.php and re-run the installation. You will see an entry indicating if that's the case.
If the issue is confirmed to the authentication method, try
mysql> CREATE USER ‘username’#‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
after logging in to mysql console.
I'm running a local copy of WordPress on XAMPP/WinXP for development, but would like to maintain a connection to the remote database. I keep getting "Error establishing database connection" no matter what I try.
On the same PC, I can connect to the remote mySQL DB using any number of mySQL clients, and on the mySQL side, the both the user and the database are set to accept incoming requests from any wildcard domain. I can also easily ping the remote database server from my PC (though I don't know how to do it from WITHIN XAMPP).
Is XAMPP its own little universe that can't reach through to the outside world? Or is there something I'm clearly overlooking that's not letting me connect?
Errors
Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in C:\xampp\htdocs\dbtest.php on line 5
Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in C:\xampp\htdocs\dbtest.php on line 5
Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication
Edit
Thanks to #Michael for suggesting I just create a simple connection script so I can get better insight into the actual error that's being thrown. This revealed that it had to do with the old_password setting in mySQL. See my Answer below for a full description of how to resolve this issue.
Here's the test script I put inside my xampp\htdocs folder and tested out:
<?php
$mysqli = new mysqli('my.server.address', 'user_name', 'password', 'database_name');
if ($mysqli->connect_error){
die ("Connect error: " . $mysqli->connect_error );
}
I'm not really clear on why this became an issue on my XAMPP installation, since I'm also running PHP 5.3.x on the server's local box and wasn't experiencing those issues there. However, it has to do with my mySQL server running in "old password" encryption mode. Newer versions of PHP won't allow those kinds of connections, so you need to update your mySQL server to use the newer password encryption. Here are the steps, assuming you have control over the mySQL server. If you don't, that falls out of the scope of my knowledge.
locate the configuration file for the mysql server called my.cnf. I found mine at /etc/my.cnf. You can edit it with sudo nano /etc/my.cnf
Look for a line that says old_passwords=1 and change that to old_passwords=0. You have now told the server that the next time it is run, and it is asked to encrypt a password using the PASSWORD() command, it use the new 41-character encryption rather than the 16-character 'old' style encryption
Now you have to restart your mysql server / service. YMMV, but on Fedora that was easily done with sudo service mysqld restart. Check your OS' instructions for restarting the mysql daemon or service
Now we have to actually edit our user table within mysql. So open up an interactive shell to mysql (on the server you can type mysql -uYourRootUsername -pYourRootPassword)
Change to the mysql database. This is the database that holds all the good stuff for server operation and authentication. You must have root access to work with this database. If you get an 'access denied' you're SOL. Sorry. use mysql; will switch to that database
Now we want to update the user that was giving you grief. Ultimately you'll probably want to update all your users, but for now, we're just focusing on the user that threw the error. update user set Password=password('YOUR_PASSWORD') where User='YOUR_USERNAME';
Now you just need to tell mysql to use the new password for authentication when that user attempts to connect. flush privileges;.
You should be good to go!