Has anyone successfully connected to MySQL from Ruby? - mysql

I'm starting to get a bit desperate in my attempts to get a ruby script to connect to MySQL.
I've given up on DBI, as I just don't seem to be able to get it to work no matter what I do. I figured I might have more luck with just using mysql.rb from ruby-mysql. However, in using that I get the following error:
./mysql.rb:453:in `read': Client does not support authentication protocol requested by server; consider upgrading MySQL client (Mysql::Error)
I gather from googling that error message that this means my version of MySQL is too recent and doesn't support old-style passwords. I'm on a shared server and don't have root access, so I can't make the changes recommended to the MySQL config.
My version, btw, is:
mysql Ver 14.7 Distrib 4.1.22, for pc-linux-gnu (i686) using readline 4.3
Has anyone succeeded in getting ruby to connect to MySQL? I've been trying under Windows, since I have admin access on my Windows machine, but if there's a way to do it without root access on Linux, that'd be even better.

Sounds like you've run in to a MySQL quirk. Some time around version 5.0 they changed the format of connect passwords. It's an easy fix, though: http://dev.mysql.com/doc/refman/5.1/en/old-client.html
(Also, check out the Ruby Sequel gem, it lets you do some real fun stuff with all sorts of databases and without the overhead of ActiveRecord: http://sequel.rubyforge.org/documentation.html )

There is a good summary of how to do this here: http://rubylearning.com/satishtalim/ruby_activerecord_and_mysql.html

I haven't had any issues with connecting to MySQL from Ruby on my test machines.
You mention that you're using a shared hosting provider. If they have that old of a ruby-mysql version that it's not compatible with the new style passwords, perhaps their support staff can make the changes you need made to the user row(s) in MySQL.

What are you looking to do? I think it is possible to use the ActiveRecord component of Rails to establish a connection to MySQL. I'll see if i can find some documentation to back this up, and i'll update this answer.
link to ActiveRecord/MySQL integration
Update: to use ActiveRecord for the purpose are looking for, you will need to create the various model classes that represent the tables you are pulling data from, and specify their relationships. Once that is done, you will be able to do something like:
SomeModel.find(:all, :conditions => ['some_column = ?', some_value]
I've used this approach in the past to provide my Rails apps with access to WordPress data.

It may be that you're using an older version of mysql and need to upgrade it.

Related

unable to create connection to mysql from C++Builder

I have C++Builder Community Edition. I am trying to create a connection from a blank project to mysql server. When I do a test, after supplying the right username and password, I get this error message:
Error: [FireDAC][Phys][MySQL]-314. Cannot load vendor library [libmysql.dll, libmariadb or libmysqld.dll]. The specified module could not be found
I was under the impression that one of the selling points of C++Builder is how easy to create a Windows form for database programming?
It is Relatively easy! However you do need to read the docs and understand how FireDac works with C++ Builder/Delphi. One big consideration is the correct bitness of your executable, x86/x64, and which client libs you have on your machine?
If it is x86 then you can use the FireDAC Explorer from within the IDE to get connected, if you have set up the connection definitions correctly and, as Spektre wrote, have MySQL running locally, it will connect? The community version only supports local connections.
Specifically you need to ensure that the MySQL connection definition or string contains all the needed entries. If you're using Windows look in the file located at C:\Users\Public\Documents\Embarcadero\Studio\FireDAC\FDConnectionDefs.ini and make sure it is setup with the proper information.
Read the docs to see how FireDAC uses connection definition files and/or strings. It does take a little effort to get it all working together so you have to be willing to learn it! If after doing some of this, post again with what you've found and be specific and you may find people be willing to help you more.
Embarcadero FireDAC Docs

Confused with different types of MySQL applications to install

I'm very new to MySQL.
My question is about installation of MySQL on my Mac (Mojave OS) to learn and practice it to later use it with node.js.
First I got it with Homebrew, but then I wasn't able to use it with the Workbench - I set up the password for root user but I didn't find any commands list to work with it since it refused to do any operations with it in workbench and I didn't find any command.
Then I downloaded Community Server - I have a server through system prefs, but I don't have a command line interface - which I need for writing queries.
After that I downloaded MySQL Shell. But as far as I researched I found that is it not standard CLI (found it here https://stackoverflow.com/questions/58367813/how-to-uninstall-mysql-shell-on-macos).
My question is next.
As an example, when I started learning MongoDB I had MongoDB Compass and MongoDB Shell - one helped me to work with commands, the other one helped to see results visually.
MySQL has a language which I want to learn and practice with (SELECT, USE etc.). How can I do the same what I did with MongoDB but in the case of MySQL? What should I install, and why Homebrew MySQL version is different than any other MySQL version (even commands - such as mysql.server start) and there is no documentation for it in MySQL docs?
Unfortunately, there's no such nice installer for macOS as there is for Windows. Instead you have to install the different parts individually.
For the type of work you plan to do I recommend to install at least 2 pieces:
The MySQL server, which holds your data. On macOS this comes with a preferences pane, which you can use do some basic management of the server (start/stop, directory settings).
MySQL Workbench, a visual design, query and management tool. That will give you GUI support for your DB work.
The server also comes with the classic shell, which you can launch by running mysql in a terminal. That's sometimes quicker for simple work, compared to launching a full GUI.
A better command line tool is the MySQL Shell, a new and highly improved variant of the classic shell, which will eventually replace the old classic shell entirely in the future. So it's certainly no mistake to install that too.
I hope that clarifies which pieces are required to start working with MySQL.

When do I use libmysql-6.1.dll vs libmysql.dll?

I'm using HeidiSQL to edit a MYSQL database, and it's asking which library I want to use for the edits:
libmysql-6.1.dll
libmysql.dll
How do I know which one to use?
These alternative libmysql*.dll and libmariadb*.dll libraries are there to solve (SSL) connectivity issues on newer MySQL and MariaDB servers. For example on MySQL 5.7, some users reported the following error with the older libmysql.dll:
ASN: bad other signature confirmation
Using libmariadb.dll may cause another error:
Unknown SSL error (0x80090308)
Especially when you provide a SSL certificate, you may run into such issues.
For this and any other connectivity issue, HeidiSQL provides alternative libraries the user can try. Apart from that, I never heard of any other advantage or disadvantage of one or another of these libraries.
While the question of which library to use for MariaDB seems pretty obvious (libmariadb.dll), what to make of the other two?
As a clue, I looked a the file properties.
libmysql.dll shows ProductVersion 5.6.6.0
libmysql-6.1.dll shows ProductVersion 6.1.11.0
Given that these files are included in HeidiSql v11.3, I concluded they are NOT generated by building HeidiSql. So, where did those version numbers come from?
Poking around in C:\Program Files\MySQL\MySQL Server 8.0\lib, I see a libmysql.dll there too (ProductVersion 8.0.25).
So, my guess is that HeidiSql acquired those files from builds of MySQL. And the newer one (libmysql-6.1.dll) is probably the better bet for current releases of MySQL.
That does leave open the question of where the number "6.1" came from. It doesn't appear there was ever a 6.1 release of MySQL?
And it also doesn't address which one is best for MSSQL, PostgreSQL, etc. But that wasn't the question here.

Access MySql with HeidiSql

I do project and I use MySql. I like HeidiSql interface and generally this, so I would like to connect to my local database. But I really feel and maybe I am dumb because whatever host name I put I have errors. Anyway when I type ##hostname in cmd I see my windows authentication username, which also does not work for me.
Mysql Workbench work properly...
Default authentication plugin for MySQL has been changed in recent versions. Not all client programs out there have added support for it yet. You can check if HeidiSQL has released any latest version which adds this support. If it is not, then only solution is to change default authentication plugin on MySQL server and recreate the user. It is described in below links.
https://www.heidisql.com/forum.php?t=24939
https://github.com/HeidiSQL/HeidiSQL/issues/163

Setup MySQL workbench with Xampp in Windows 8

I'm trying to get back into PHP and MySQL development since i've found out that MySQL now allows stored procedures. I work with these at work on an Oracle database and use PL/SQL developer to create them. I was looking for a similar sort of interface for MySQL and was pointed in the direction of MySQL workbench. I'm using Xampp as my test server setup and would like to link MySQL Workbench to MySQL on this server however I'm stuck at one of the stages in the installation. I'm trying to create a new server instance and have been successful as far as testing the database connection however on the next page it asks me to set the 'windows configuration parameters' for this machine and failes to discover a MySQL service. I have ensured that both the Apache server and MySQL services are running in Xampp but do not understand why a MySQL service cannot be found and is not being displayed. Has anyone else encountered this issue when trying to use MySQL Workbench and if so, how did you amanage to get it up and running? I'm using Windows 8 and don't know if this is the reason a service isn't being found. I apologise if this is a really simple question with a simple answer however I have only ever used PHPMyAdmin before which is relatively simple to setup.
I have found problems with the packaged *AMP systems. They don't always install things the way other applications expect. e.g. The MAMP system doesn't work well with Python. it's quite easy to install each of Apache, PHP and MySql on Windows (and two of them are already on the Mac and Linux)
If you use the standard MySql install you should have no trouble installing the Workbench, I've done it on both Windows and Mac.
I have found it a bit flakey at times, it won't connect to older server versions and tends to crash when running long scripts. It also doesn't have a great UI for queries, A good program like PLSQL Developer to TOAD would be nice.
The service detection is rather simple. It expects that the service contains "MySQL" in its name. This is planned to be improved later. For now rename your service to something like "MySQL Xampp".