db connection initiated multiple times by rails app - mysql

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.

Related

How can i run MySQL and MariaDB database server at the same time and access them at phpmyadmin?

First i want to have two different database servers on Windows 10
A MySQL database server and a MariaDB database server
Second; I want to be able to access them at Phpmyadmin (On Phpmyadmin login screen, I am expecting to see 'Servers' dropdown list to pick either MySQL Server or MariaDB server)
How can I achieve this on Windows 10 ?
1. It's posible, for run mysql and mariadb, u need config one instance more, because mysql and mariadb have similar core. (Is same to install two mysql server instance in one machine). Here one tutorial for install instances of mysql on windows. Multiple MySQL Instances on Windows
2. phpmyadmin requires a web server, PHP, and a browser. But... i think that isn't possible, because this is connect simultaneously to two database server via only one connection of phpmyadmin in your browser, and i think isn't logic support. I think that u can try is install two phpmyadmin. One for mysql and other for mariadb. Check docs in the web site, maybe u can obtain other solution. Phpmyadmin
Regards ✌🏼️

RDS MySQL 5.7 and Entity Framework

I just upgraded to the latest MySQL RDS version, from 5.6.
Since we're still using some .NET based on Entity Framework Database First, we cannot run "Update" on the model.
This is a known issue in MySQL 5.7.
A way to fix this, is to run the following on the database:
set global optimizer_switch='derived_merge=OFF'
But, when I do so, I get the usual error about missing SUPER privilege.
I've already added "trust_creators" to my parameters group, and rebooted the instance.
What to do?
The optimizer_switch system variable -- like all configurable system variables -- is configured in the RDS Parameter Group.

Wordpress site is using many connections to 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.

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

What's the set up database on Heroku?

I have deployed my Rails 3.1 app with the MySQL database to Heroku and there everything works fine. I mean, into database are saved the chars right (seems to be used UTF charset on a databases on Heroku).
But when I will run the command heroku db:pull (this command will download a whole database from Heroku into the database on localhost), so the downloaded data stored in databased have bad coding - a chars are displayed bad (it looks like my local MySQL database have a different set up of charset than the MySQL on Heorku).
Could anyone give me a tip, how I can find the set up of charset used on Heroku database and how to use it on my local MySQL database?
Many thanks!
All is not lost - you really don't have to use PostgreSQL if you don't want to.
If your database is small enough (which it will have to be since the Heroku PostGres DB is also 5Mb) and you would prefer to remain on mySQL then you could use the ClearDB mySQL addon - http://addons.heroku.com/cleardb - their entry level DB is free and is the same size as the Heroku Shared PostGres DB that you get by default but be careful that the number of connections is limited so don't be going crazy with your web dyno counts.
Once you add the addon if you look at the output of heroku config then you can use the DATABASE_URL to create a connection in your favourite mySQL administration tool locally to restore/backup etc data to ClearDB. You may even find heroku db:push would work but personally I've not tried that so would be guessing.
The problem is that Heroku does not use a MySQL database in production, but a PostgreSQL database.
Therefore you will run into all sorts of issues pulling and pushing data from a different database engine. Taps is an activerecord based process that will reduce this problem but not all the time.
Ideally you want to use PostgresSQL on your development machine (install via Homebrew for simplicity on OSX) and you'll not see any more of these problems.
Alternatively, use one of the MySQL addons as described in the comments in the question.