MAMP cannot connect to localhost - php

Big picture: trying to update a 5 year old WordPress site without losing all the calendar plug-in posts.
Macro: downloaded MAMP to setup a local test site. Cannot get past index page to connect to database.
What works:
Index page shows my test sites (I have three versions of wordpress
Installed (3.0.5 / 3.9.1.1 / 4.4.2), so I can incrementally test and
upgrade)
I can login to phpMyAdmin no problem
I exported the old database to a .sql file, then imported it up to the new Local database, it showed up fine, but tells me "Your PHP MySQL library version 5.1.73 differs from your MySQL server version 5.5.48"
The wp-config.php usernames and passwords all match to the database
After many searches and most of the day trying different things, I am stumped. Obviously, I am a complete noob to MySQL and PHP.
What I have tried:
Changing port to 90 instead of 80
Changing the user to 'root' and 'admin'
Changing from define('DB_HOST', 'localhost’); to define('DB_HOST', '86.42.246.7:80’); and define('DB_HOST', '86.42.246.7:90’);
Notes:
I initially edited the files with textedit, but noticed it was changing single quotes to leave syntax errors - now I'm using Dreamweaver.
Is it possible I could just import each table one at a time into a newly created database?
Please help me out!
EDIT
I changed the database password, but I got this error message
"phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server."

Related

when using $wpdb sudden connection rejection without changing anything. Access denied

WP version 5.5.3 - updated days ago
php version 7.3.24
running locally on server
Can not create a backup using duplicator
Occours bothi inside WP admin pages, so internal connections and external through php requests
I am suddenly receiving the following error but have not made any changes to any file on the server, nor within wp itself -
WordPress database error: [Access denied for user 'database-name'#'localhost' (using password: YES)] .
THIGNS I HAVE DONE TO FIX -
I have verified the wpconfig password and the db password match. I actually re-updated the db by copying the password listed in the wpconfig file and pasting it to the db.
Searched a lot of solutions on here
checked that the db is up and running by logging in using MYPHPADMIN
What am I missing and how do I get to the root of the issue that is causing this? No console errors are shown.
Have you considered the possibility of for the likes of using an online SQL instance such as AWS RDS, given the correct permissions for the database to be accessed, or are you running it locally?

Error connecting to SQL host, PHP Script: PHPVALLEY Microjob Script

I installed the php script and all wen well but the problem is at the final step, when I need to fill the database information, when I field the database information I find that i am getting an error that says "Error connecting to SQL host", so I try and try in different ways but there is no solution, nevertheless, I installed the same script on my localhost and all went well without problems, my Hosting Provider is: Siteground
Filling Database Information Image
Showing the Error Image
You must grant write permissions to the connect.php file for the user who is running the web service for example apache.
Have you ssh access to the server?
If your application cannot connect to the database you should make sure that:
Your application is using the correct MySQL hostname: localhost
Your application is using the correct MySQL database / username /
password.
Don't forget to specify your MySQL username and database with the
prefix yourusername_ in front of its given name. For example, your
cPanel username is siteground and you have named your database
joomla. In this case you have to refer to your database as
siteground_joomla;
Source: https://www.siteground.com/kb/my_script_cannot_connect_to_my_database_/
Another good idea would be to try to use your cPanel username and password for the Database User and Database Password. This will rule out whether you have granted all privileges to your database user.
Also you should change the permissions of your connect.php file to 755, as if you set them to 777, this will cause an internal server error.

Where is /usr/local/lib on online server

I have a server hosted on 000webhost.com
In the file manager there is a public_html folder where I store my website files, but no \usr folder.
Generally I could just access this file through the command line or terminal but this is not the case on this server. Unless there are command line tools that I simply couldnt find (I know it is a linux server);
I ran phpinfo() and the configuration file path was in usr/local/lib but I have no idea how to access that.
Any ideas? Thanks in advance.
Go to http://www.000webhost.com/faq.php look at the section on connecting to MySql. Your solution is likely there.
Here is a synopsis:
If you cannot connect to MySQL server, there could be some causes:
- Incorrect MySQL hostname.
Never use 'localhost' as your MySQL hostname! You can find your MySQL hostname by logging on to members area, entering control panel and clicking on MySQL icon.
- Incorrect MySQL username / password or database name.
You can find / setup MySQL username and database by clicking on MySQL icon from control panel. And you can change MySQL password by clicking on phpMyAdmin icon.
- Database failed to setup.
In a very rare cases MySQL database can fail to setup. To confirm this, please try to enter phpMyAdmin for any database. If you see database there, that means it setup was successful. And if you get access denied error by trying to enter phpMyAdmin, please delete the database and setup the same MySQL database again.
Please note that always you must give about 1 minute for any changes to apply on server.
If you still unable to connect to MySQL you check if it is server or your script problem in this way: if you can enter phpMyAdmin and see you database there, that means everything is working fine on our side. It's a problem with your PHP script.

WordPress, Apache, MySQL, and Mac

I tried setting up WordPress on a Mac, I got Apache running, PHP is up and going and MySQL is running. I put WordPress in library/webserver/documents and I visit localhost/wordpress/wp-admin to do the install, and get an error establishing database connection.
So I check the database information and password and database name. Everything is correct down to the last syllable in the password, name and database name....
Why am I getting this? I have set up WordPress on Ubuntu and Windows without any issue, but why does a Mac present a problem?
With wp_debug on, it states my password is wrong. I have tried logging into MySQL with the password given and the user name - it works... so that is clearly not wrong...
If you're using MAMP, make sure that the disk location of the virtual host is correctly configured. I.e., pointing to library/webserver/documents.

Wordpress installation - php and mysql are not talking to each other to access database?

I'm trying to get a wordpress local install working on my Mac.
I've recently set up a database, username and password using the MySQL client as per the instructions in the wordpress codex. That part is ok.
When I go to the local site on my computer I'm prompted by wordpress to set up the wp-config.php file. Putting in the same details that definitely work with the MySQL client returns an error.
Manually updating these details in the 'wp-config-sample.php' file and renaming it as 'wp-config.php' also doesn't work - I'm now greeted with a big bold message: "Error establishing a database connection".
From what I can gather, php and mysql are not communicating with each other properly.
I've changed the apache 2 configuration file found in 'etc/apache2/httpd.conf' and uncommented the line which loads the php5 module: LoadModule php5_module libexec/apache2/libphp5.so
and restarted the apache server. This has still not fixed my problem. I'm stuck on what to do next... help appreciated please!
It's been fixed now.
php was looking in the wrong place for the mysql.sock file, and couldn't communicate with the mysql database, meaning wordpress couldn't be set up.
On the command line I typed
ps aux | grep mysql
to bring up as much info about mysql that I could. From this I saw that the mysql socket on my computer is being used at /tmp/mysql.sock
Meanwhile, in the "wp-config.php" file, I changed the line define('WP_DEBUG', false); to define('WP_DEBUG', true); and refreshed my web browser that was showing my localhost setup. This now said a lot more info than "Error establishing a database connection" - infact I could see that the mysql.sock was not configured correctly at all.
Creating a 'phpinfo.php' file with just the single line of code <?php phpinfo(); ?> was the pivotal turning point for me.
Putting that 'phpinfo.php' file in my localhost directory and then viewing it from my web browser not only definitely confirmed that the mysql.sock file was not configured properly, but it also showed where the configurations were being loaded from on my machine: '/private/etc/php.ini'
The next thing I did was open up the 'php.ini' file in a text editor and doing a quick find and replace to update the correct location of mysql.sock.
Finally, a restart of the local apache server needed to be done to fully update all the new settings that I'd been fiddling about with.
sudo apachectl restart
Now everything works fine!
The Error-Message "Error establishing a database connection" indicates clearly, that the php-script can not establish the connection. This can have one of the following reasons:
Your host in the wp-config.php is not correct.
The mysql-server does not listen on that host
The user you set up in the mysql has no privileges to connect the way you are trying
The firewall blocks the access of the php-script to your mysql-host
Try to connect the database with the same settings of your wordpress using Sequel Pro (or any other GUI to connect a mysql database). If the connection works, the problem 2. and 3. isn't your problem.
Look in your firewall-log to make sure 4. is also not your problem.
If all problems are excluded (even 1. after a final check), try to run something like phpMyAdmin to connect your database, to make sure your php-installation has the needed drivers.

Categories