Wordpress site is using many connections to mysql - mysql

We have a website running on Wordpress which connects to mySQL database. Wordpress is using many connections, more than 100 and it is not closing them. We tried to close the connection inside the destructor of wordpress db connection. It has helped to some extent, but the connection count is still high. When 3 people connect the site, the connections count is going above 100. Can anyone help us in troubleshooting the issue?
We are using mySQL 5.6 and WordPress 3.9.1

Install the Wordpress DB Driver, set to PDO, and add PDO::ATTR_PERSISTENT to your initial connection constructor. This will use the same connection for all subsequent connections that connect using the same credentials.

Related

Can I use remote database for rackspace cloud server?

We previously had a company setup our website on a web host and they set it up on a rackspace cloud server (unmanaged). It is an expression engine website.
I have now rebuilt the website into Wordpress but cannot figure out how to setup the database on rackspace. There isn't a database setup on rackspace now, so I'm not sure how the EE site is setup.
I am wondering... Is it possible to just load the wordpress files on the Rackspace server, then connect the Wordpress site to a remote mysql database hosted on Hostgator?
If so, does someone know a a tutorial to do this?
I'm clueless when it comes to uploading a database on Rackspace via SSH. I'm familiar with phpmyadmin but not good with unmanaged servers.
Any suggestion what would be the best for my needs? For now, I need to get the site up and running on Rackspace until I can get a managed dedicated or VPS server setup.
*UPDATE*
I have tried to change the DB host in the Wordpress config file to the IP address instead of localhost, but no luck. Any ideas? This is part of the wp-config.php file in the root directory. I have removed the values. I've tried the hostname like this also with no luck... XXX.XXX.XX.XXX:3306
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'remote_DB_name');
/** MySQL database username */
define('DB_USER', 'remote_DB_user');
/** MySQL database password */
define('DB_PASSWORD', 'hiddenpassword');
/** MySQL hostname */
define('DB_HOST', 'XXX.XXX.XX.XXX');
I'm not an expert with Wordpress but it should be possible to have your wordpress site running on a Rackspace Cloud Server connect to a database that is not on Rackspace.
According to http://codex.wordpress.org/Editing_wp-config.php#Configure_Database_Settings, there should be a file named wp-config.php in the base directory of your Wordpress site. You should be able to edit the values of the constants starting with DB_ to configure database connection settings. Specifically, you will want to change the value of the DB_HOST constant to be the hostname or IP address of your database server that is not on Rackspace.
Normally wordpress allows different database server and can connect it with different servers. But here it seems problem is not with connection settings you use. You have to give proper permissions for your IP to the database server.
Please check and add permissions to your IP on database server using your credentials
GRANT ALL PRIVILEGES ON *.* To 'dbusername'#'XXX.XXX.X.XX' IDENTIFIED BY 'dbpassword';
Check these option with your database administrator and try configuration again
Reference :
Wordpress database COnfigurations
While it may or may not be possible to connect to a Hostgator database from a Rackspace server (contact their respective support departments for details), I know one thing for sure: It's a bad idea anyway. Don't do it.
When they're being used for web applications, MySQL database connections are highly sensitive to latency. Each MySQL query performed by your application will be slowed down by at least the round-trip time — for instance, if there is a 10 ms latency between your web server and database server, and your application performs ten MySQL queries for each page load, your page load will take a minimum of 100 ms (10 ms x 10) more than it would without that latency. Ten queries and 10 ms is a best-case scenario, too; many web applications will use considerably more queries than that, and two distant servers may have a round-trip time much higher than 10 ms (100 ms wouldn't be unusual for a transcontinental connection).
Use a local database. If you don't know how to get one on Rackspace, ask their support team!

MySQL Workbench works and phpmyadmin does not

About 2-3 weeks ago I stopped using phpmyadmin and started using MySQL Workbench. Now, I can't connect to phpmyadmin. I tried connecting from two different computers and from the server. Tried connecting with at least 4 users and root. I am suspecting that this is Workbench's fault. During the time I used Workbench I made some changes to user privileges, but don't remember the specifics. I get "Wrong username/password".
Any thoughts ?
Looks like some of the comments have been deleted, but judging by what's left there was a suggestion for you to check your permissions for your user with hostname localhost, and it appears you did not understand that % is not the same as localhost. Many installations come with several root users, one for host localhost, one for host %, and sometimes a third for 127.0.0.1. This is normal and part of how MySQL handles permissions. TCP/IP connections match %, socket connections do not (they use localhost).
Another thing that's important to realize is that, when using phpMyAdmin, it doesn't matter what client machine you're using; what matters is what machine is the web server, since that's where the requests to MySQL come from. So you can easily get a bit confused if using a remote machine to connect to a web server running on the same machine via sockets to the MySQL server -- even though you're on a remote machine from the MySQL server, in this case it appears as a localhost connection to MySQL.
Anyway, very likely what happened was you were "cleaning up" extra users and removed one that had the opposite host value (either % or localhost); I'd simply recreate your user with the other host. That should clear it up for you.

Could not get database metadata for mysql on osx

I have a mysql database with 3000 tables, and a hibernate application. It working fine on ubuntu, but on Mac(homebrew) always show connection errors after
ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database metadata
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
I doubt some setting for mysql need to be change, but do not know which one.
Looks like your database server isn't responding.
Check the configuration files for hibernate and make sure that it's pointed at the right host for the database.
If you're using localhost, make sure that the mysql server you're running locally is up (ps or mysql command should help here) and verify that hibernate is either communicating over the UNIX socket, or that you have networking turned on in your local server (since by default it's usually off and required for TCP/IP access, even to localhost).
Fixed after added 'max_allowed_packet=20M' to my.cnf

db connection initiated multiple times by rails app

Connecting to database specified by database.yml is called multiple times by my rails app, even when the MySQL RDS db instance is up and running. How do I debug this issue?
Which version of Rails? Which version of the MySQL gem? (You can check the versions in Gemfile.lock, or with bundle show).
In database.yml, there's also a pool parameter which specifies how many DB connections should be made (to accomodate multiple threads using the same database). By default, this is at 5.

does openfire interfere with mysql or phpmyadmin?

I have installed php, mysql, phpmyadmin on windows server 2008 and everything is working fine. Now, I installed Openfire and i connected it to mysql database. the problem that i am having now is when every i run openfire i can't connect to database or login phpmyadmin. It seems like openfire is interfering with mysql ports! I am using port 3306 for mysql. I belive openfire is using 9090 and 9191.
so when I have open fireopen my php scripts will not be able to connect to the database and also i won't be able to log in to phpmyadmin. But when i close openfire then everything works fine again.
Can any one help me with betting both to work next to each other eith no issue please?
Thanks
I found the issue. the problem was that a min connection in openfire was set to 100 and Mysql max connection was also set to 100. So I have increased the max connection allowed and that fixed the issue.