WordPress Error establishing a database connection MySQL on non-default port - wordpress

I'm trying to install wordpress on my localhost with XAMPP. My Apache module is on ports 80,443 and my MySQL module is on port 3307 (default is 3306). I can't start installing wordpress. After entering localhost/wordpress in my browser there apears error "Error establishing a database connection". I don't have wp-config.php file i guess it creates after starting installation which i can't start
I tried changing wp-config-sample.php but it looks like it doesn't change anything i also tried creating wp-config.php on my own and changing DB details there

You have to change config.php not config-sample.php.
define( 'DB_NAME', 'your_dbname' );
define( 'DB_USER', 'your_dbuser' );
define( 'DB_PASSWORD', 'your_dbpasw' );
define( 'DB_HOST', 'localhost:3307' );
That's all you need. Just append ":" after localhost (or your machine ip address/host name)

Having a database connection issue would mean there's a "wp-config.php" file being used, and the credentials are incorrect -- hostname, port, credentials, or possibly not having a database created yet.
During an initial setup, WordPress will create the wp-config.php file with the MySQL credentials, when the connection is a success. If you're not getting a setup page, review your "wp-config.php" file, or delete all of the contents and start over with a new WordPress download. Extract the zip/tar.gz archive, and move the contents in the "wordpress/" folder into your site's DocumentRoot.
You can also test your MySQL credentials with this command:
mysql -h localhost -P 3307 -u DatabaseUsername -p
The uppercase "P" is for port, and the lowercase "p" is for password. If entering the password at the prompt is successful, check that you've got a database with show databases;.

Related

WordPress 'Error establishing a database connection'

I am trying to start my 1st project in WordPress and put this data
Database Name : wp-project-1
DB_USER : root
DB_PASSWORD : ``
DB_HOST : localhost
Table Prefix : wp_
And in my wp-config-sample.php:
define( 'DB_NAME', 'wp-project-1' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', '' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
But it says error like this when I submit them:
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.
Are you sure you have the correct username and password?
Are you sure you have typed the correct hostname?
Are you sure the database server is running?
If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
Here I am using xampp server, and my xampp port number is 3307 (I change that cause 3306 was busy every time.)
How can I fix it?
on xampp you can open control panel where it says apache hit the config select php ini and find the following
mysqli.default_port=
Please change your wp-config-sample.php file to wp-config.php

ftp command in one line for wordpress

I want to place my uploads folder from wordpress on a different server.
I read that in wp-config.php I had to add:
define('UPLOADS', 'folder where to move the files');
And in order to move the files to a different server I have to place the ftp argument instead of the folder.
However I keep getting an 'unable to create directory' error. I tested with ftptest.net to see if the ftp is working and this works correct.
This are my credentials I enter:
Host: <ip-adress>
Port: 21
Username: user#domain.com
Password: <password>
Protocal: Explicit FTP over TLS
I tried these 2 command with the same outcome of unable to create directory:
define('UPLOADS', 'ftp://user#domain.com:password#ip-adress:21');
define('UPLOADS', 'ftp://user:password#ip-adress:21');

How to setup Wordpress with https://box.scotch.io/?

I have setup scotch box and now trying to setup WordPress with scotch box how would I go by doing this please.
I have recently set this up.
To set up Wordpress, place the Wordpress install files inside the scotch/public folder that is created when you first run scotch.io
You will then need to ssh into your vagrant box, and set up a new MySQL database. You can import a dump via the command line, or export/import using Sequel like I did.
Even though mod_rewrite is already enabled in scotch.io, I found it helpful to restart the apache2 server in the vagrant box.
Once that's done - you should be able to navigate to 192.168.33.10 on your browser to see your install.
Set the wp_config.php database host to localhost.
I found the following code great for getting permalinks working, place this at the top of your wp_config file:
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ?
's' : '';
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
$url = "http$s://" . $_SERVER['HTTP_HOST'] . $port;
define('WP_HOME', $url);
define('WP_SITEURL', $url);
unset($s, $port, $url);
If you get a Database access error - this is a good sign you're on the right track, you need to put in the user: root / pass: root details fro the vagrant web host to access the database inside the box.

Your PHP installation appears to be missing the MySQL extension which is required by WordPress - for multiple instance

My system is running 2 MySQL instance
One is running on port 3306 another on port 3307
Now I want to connect my WordPress to MySQL which is running on port 3307
But I am getting error when I try to access index page - Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Please let me guide how to resolve the problem.
Edit the definition of DB_HOST in your wp-config.php file by adding :3307. From the documentation:
If your host uses an alternate port number for your database you'll
need to change the DB_HOST value in the wp-config.php file to reflect
the alternate port provided by your host.
For localhost
define( 'DB_HOST', 'localhost:3307' );
Other
define( 'DB_HOST', 'mysql.example.com:3307' );
Replace 3307 with whatever port number your host gives you.
Solution 1:
Check your php.ini and make sure that you have extension=php_mysql.dll un-commented.
Solution 2:
You can use the following library if you do not have mysql_connect enabled but have PDO enabled:
https://github.com/AzizSaleh/mysql
Create a new file: wp-content/db.php and place this code in it (update your path to mysql with path to your extracted folder):
<?php
$pathToMySQL = 'C:\\xampp\\htdocs\\mysql\\';
require_once($pathToMySQL . 'MySQL_Definitions.php');
require_once($pathToMySQL . 'MySQL.php');
require_once($pathToMySQL . 'MySQL_Functions.php');

WordPress FTP update on EC2 server

I have an AWS EC2 instance running an Ubuntu 12.04 web server that I host Wordpress on. For Wordpress to update, it's asking me to supply FTP credentials. I have set up FTP according to this post: http://stephen-white.blogspot.co.uk/2012/05/how-to-set-up-wordpress-on-amazon-ec2_31.html
But the FTP user I created (ftpuser) can't log in. WP only gives very vague errors, but I tried using FTP in the OSX terminal, which gives 'Login incorrect', but the password is definitely correct. I can FTP in using my normal username and password.
This is the content of my vsftpd.conf file (I've removed all commented out lines):
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pasv_enable=YES
pasv_min_port=14000
pasv_max_port=14050
port_enable=YES
pasv_address=54.241.13.224
pasv_addr_resolve=NO
This is an nmap of the servers ports:
PORT STATE SERVICE
20/tcp closed ftp-data
21/tcp open ftp
22/tcp open ssh
80/tcp open http
443/tcp closed https
14000/tcp closed unknown
The /var/www (where I have Wordpress installed) folder is owned by ftpuser and this is the entry for the ftpuser in the file /etc/passwd:
ftpuser:x:1001:1001::/var/www:/sbin/nologin
I'm only an amateur server admin, so haven't a full clue of what I'm doing. Anyone have any ideas why this is happening and what needs to be done?
If you are receiving the following error message "Login incorrect" on AWS EC2:
331 Please specify the password.
Password:
530 Login incorrect.
ftp: Login failed
There is a problem with login using Shell. To overcome this there is one further step missing after the following in that Blog Post:
Add an FTP user, giving access only to the WordPress files and for additional security >ensuring the user can not open a shell:
useradd ftpuser -d /var/www/html -s /sbin/nologin
Add the following:
Add /usr/sbin/nologin on to the last line of /etc/shells file:
$ vi /etc/shells
/usr/sbin/nologin
Try logging in again using your FTP client. That's how I got it working on my instances.

Resources