mysql not connecting to environment after ruby-2.2.2 upgade - mysql

I have just upgrade our legacy ruby app from ruby-1.9.3 to ruby-2.2.2. The app runs fine locally, I have successfully deployed it to our staging environment but for some reason it is now having issues connecting to mysql.
May 19 16:09:43 io-sbx-app-01-a3 rails[30750]: Reconnected to ActiveRecord
May 19 16:09:38 io-sbx-app-01-a3 rails[30738]: Verified ActiveRecord connections
May 19 16:09:43 io-sbx-app-01-a3 rails[30750]: Disconnected from ActiveRecord
Is there anything I need to consider with regards to connecting to mysql ? We currently use the mysql2 adapter

Here's what i can think of, with the information i have
1) see if the mysql service is up and running
2) see if the reconnect flag to true in database.yml.
3) in the staging environment, is the database service running in the same machine / on a different machine. If different machine, there might be some network related issues..
4) during your deployment process, do you re-start the mysql service. if not, it'd be good to try that..
5) you can check mysql.err and mysql.logs to see what happened from the database side of things..

Related

Pomelo MySQL (.NET Core) Can't Recover After Database Failure

Last night AWS RDS had an "Internet Connectivity Issue" that was resolved a short time later. However, my app (which runs in .NET Core and connects to an RDS MySQL instance via Pomelo.EntityFrameworkCore.MySql) could never re-establish a connection to the database even though the MySQL server was back online. I tested connecting from my own local machine and it worked just fine. I then re-deployed the .NET Core app it everything started working again.
Is there something that I need to re-create (the db context perhaps), or is there something that is being cached that I need to flush to try to connect again? I connect via hostname, and my connection string looks something like this:
server=something.somewhere.us-east-2.rds.amazonaws.com;userid=XXXX;password=YYYYY;database=ZZZZ
Here is the Exception being thrown:
MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySqlConnector.Core.ServerSession+<ConnectAsync>d__56.MoveNext (C:\projects\mysqlconnector\src\MySqlConnector\Core\ServerSession.cs:239)
and here is how I create my db context in Startup.cs:
services.AddDbContext<BlayFapContext>(opt => opt.UseMySql(Settings.Instance.SQLConnectionString));
Any help would be greatly appreciated.
Giawa
Okay, we worked out what happened. Pomelo's MySQL wrapper had an issue as outlined in their git repo here: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/434
Basically, if a MySQL database is not available when the connection string is first used then it will be cached as invalid and will never work again. You can easily confirm this by launching a service with no MySQL connectivity, verify it doesn't work, then launch MySQL and confirm that the service still doesn't work. It can never establish a MySQL connection after the first connection string is found to be invalid.
They patched it shortly after the 2.0.1 release, but they haven't updated Nuget with a new version since then, despite the issue being found 6 months ago. So, the fix is to checkout their repository source code, and patch it ourselves. We found the fix here works just fine: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/pull/456
So, why was the connection string retried? We already had a successful connection! It turns out that the internet connectivity issue with the Ohio data center was not limited to RDS, but also affected EC2. Our EC2 instance was rebooted as part of the fix, and the MySQL connection wasn't valid when it reboot due to the continued connectivity issues. The state of that connection was cached, and even though the MySQL server came back online our service was toast.
Giawa

Power BI not connecting to MySQL

I am trying to connect Power Bi (Desktop version) with my online amazon mysql database. It demands for following information once you try to establish connection
Server: server ip
Database: database name
Username: mysql username
Password: mysql password
First time I received a bit lengthy error, which was because of unavailability of mysql-connector-net-6.6.5.msi. So I followed this link to solve the issue
Microsoft Power BI connect to mysql
After installing mysql-connector I am facing another error.
Whats wrong? One of my mates has successfully connected using the same credentials that I am using.
Okay, I just figured this out for myself. I'm able to connect directly to a MySQL database on port 3306. As I understand, it would be more secure to go through an SSH tunnel, but this doesn't work yet with Power BI.
So here are instructions for connecting directly:
First, let's make sure that everything besides the PowerBI connection is working.
1) Download and install the correct version of the MySQL/Net Connector. Right now, version 6.6.5 is the one that works. But from other forums, and from within PowerBI itself, I linked to other versions that did not work. (You will know it isn't working, because you probably won't be able to even open Get Data/MySQL Database/Connect.)
2) See if you can connect remotely to your database through some well established utility like MySQL workbench. If you can't,
- look at ports on the remote server. Here's a cool utility to check ports&IPs: http://www.yougetsignal.com/tools/open-ports/
- Check the permissions of the DB user. Realize that they may be affiliated with an IP address: 'username'#'ipaddress'. So that user can only connect for a particular IP.
- Check the bind address setting. In newer versions of mariadb, it should probably be commented out. I'm not sure about older version and pure mysql.
- other troubleshooting.
So after that's working, here are the settings which worked for me in MySQL:
go to Get Data/MySQL database/connect
Server: ipaddress:3306 (include ":port#")
Database: dbname
PowerBI interface. Select "Database" instead of "Windows"
Make sure you select Database instead of Windows.
Good luck.
Just a small tip. If you haven't already, restart the machine you just installed the connector on. I had to restart before it started working.
My solution for this was to add the port number to the server name/ip
eg. 192.168.0.1:4664

Unable to connect to any of the specified MySQL hosts in NHibernate, MySql

One of the client is reporting this issue happening in our application. NHibernate throws Unable to connect to any of the specified MySQL hosts in the middle of the app running, so it is not a mistake in the configuration. It happens randomly, but always when the transaction is opened.
I saw this:
NHibernate, MySQL, Windows Server 2003 -- connection problems
But the server in my case is Windows 2008. And app opens only single connection simultaneously. MySQL version is 5.5.28. Server is on the remove machine
Unfortunately the app requires the HW I do not have, and I cannot reproduce it locally.
Any ideas or directions I need to dig in?
Try connecting using the full directory name, e.g. instead of Server=SRV use
Server=SRV.yournetwork.com
It might be that is has trouble resolving the server name.

Toad for MySQL connection problems (Win 7 to Linux)

I have a MySQL instance running on a Linux box, and a Mac which also has Win7 (Bootcamp/VMWare). I can connect to the MySQL db from Navcat Lite for Mac with no problems, however, I prefer Toad. I installed Toad for MySQL for Win7 but it just CANNOT connect to the db. I installed ODBC for MySQL and it CAN successfully connect to the db, so it's not a firewall issue (I also tried disabling the firewall)
Here is a quick summary of what I see:
MySQL db running on Linux box, within my network, port 3306
Mac can successfully connect to the db through Navcat Lite
Toad for MySQL (Win 7) CANNOT connect to the db using a TCP connection (tried increasing connection timeout to 30 sec)
ODBC Driver for MySQL (Win 7) CAN connect to the db using the same credentials
Any help would be much appreciated!
Here is the error that Toad throws:
System.TimeoutException
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Check this bug report. Might be what you are facing.
link:
http://toadformysql.com/thread.jspa?threadID=32380
Taking in account your recent outcome from the packet sniffing, i do believe it is related to this bug report.
Toad seems to use the .net framework, according to the release notes it requires version 3.5 to be installed and the security policy set to unrestricted.
So, do you have .net 3.5 installed? if so, can you try to run toad as administrator?
PS: to set the security policy and i'm quoting from the link above:
To run Toad, the .NET security policy must be set to Unrestricted. To modify the security policy:
Select Control Panel from the Windows Start menu.
Double-click Administrative Tools.
Double-click Microsoft .NET Framework version Configuration.
Select My Computer, and then select the Runtime Security Policy
node.
Select Evaluate Assembly from the list of tasks in the right panel,
and locate and select Toad.exe in the File field.
Click Next and set the permission to Unrestricted.
Hope it helps, keep providing information.
I have the same issue with one my MySQL installations. I am able to connect using MySQL Workbench, but Toad for MySQL does not connect. Also, every application I created using MySQL .NET Connector also times out.
The solution I found was to connect the machines to the Internet and they connect instantly. I believe it has to do with the Connector and not Toad. Updating to a version beyond 5 should help.
Using freeware Toad for MySQL 8.0.0.296 (64 bit), instead using connection type TCP, use connection type SSH, insert database data like Host IP, user, password, default database and port. Also add SSH port, SSH Host IP, SSH user and password. Toad will emulate onnection directly to SSH console, the interface is the same, it works very fine, the error "Character set 'utf8mb3' is not supported by .Net Framework" is gone.

Connecting to remote MySQL problems

Having a bit of a problem with mysql...
Mysql 5.1 on windows 2008 server iis7
Site on windows 2003 server iis6
[sorry but can't move to linux kids! ;)]
In the process of shifting a site to a new server so I have moved the database 1st and connected the site to the new database. I tested the connection before moving but now the site is connecting to the new database I am having problems....
connecting via PDO the page hangs for an age before getting 'too many connections' error. Monitoring the server I see MANY threads of: 'unathenticated user' from the ip address of the host the site runs on.
I also see a thread for the connection with the correct user name in my config file and I am a total loss as to what is going on.
Any help would be very much appreciated
'unathenticated user' from the ip address of the host the site runs on
A stab in the dark, but this could be some script or process trying to connect to the database server with wrong or empty credentials.
Also, here's a report from somebody who had similar problems - in that case, it was the DNS lookup that caused the problem.
I had a similar situation on my setup where the database lived on a different host than
the webserver. I found the "unauthenticated users" were connections from the webserver
that were hanging on DNS lookups. Don't know if this is a mysql bug or a bug with my
firewall / other setup, but a couple of fixes I found were...
1) start mysql with --skip-name-resolve (you may have to change your mysql permission
tables to have the host's IP instead of hostname, including localhost)
or 2) add the connecting host to your /etc/hosts file.