This should be fixed in the latest LTS-branches of our mysql2 fork, 0.2.x-lts and 0.3.x-lts. Use gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.2.x...
...lts' # for Rails 2.x gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts' # for Rails 3.x in your Gemfile, and do a bundle update mysql2 Background
We had a card that described how to install multiple mysql versions using mysql-sandbox. Nowadays with the wide adoption of docker it might be easier to use a MySQL...
...docker image for this purpose. Create a new mysql instance docker run --name projectname_db -e MYSQL_ROOT_PASSWORD=secret -p "33008:3306" -d --restart unless-stopped mysql:5.7
When MySQL refuses to use your index, you can do a number of things wrong. One of them might be conditions with improper data types. An example For example, let...
...assume you have a users table with an email field (varchar) which is indexed. MySQL will use the index when your query is well-formed: mysql> EXPLAIN SELECT * FROM users...
...databases are actually very complicated, and chances are, your making some incorrect assumptions. The MySQL innodb engine actually has four different modes for transactions: READ UNCOMMITTED READ COMMITTED REPEATABLE READ...
...are consistent nonlocking reads. The problem with consistent nonlocking reads If you open a MySQL transaction, the first SELECT statement will establish a "snapshot" of the database's state. All...
If you get a stacktrace complaining about uninitialized constant MysqlCompat::MysqlRes a system library update might broke your gem. You might have switched from MySQL to MariaDB, but forgot to...
...rebuild your MySQL gems. Try fully removing and re-installing the gem: gem uninstall mysql mysql2 bundle install
This article describes how to reset MySQL's or MariaDB's root password on your workstation. It's meant for local development purposes only, don't do this in production...
...you prefer using a password for root. Solution Step 1 is getting a root mysql shell that allows us to change user credentials. We need to stop the mysql daemon...
Ubuntu has a package mysql-sandbox that lets you install multiple MySQL versions into your user home: Install mysql-sandbox sudo apt install mysql-sandbox Download the version of MySQL...
...you want to use from mysql.com: https://dev.mysql.com/downloads/file/?id=480427 Make sure to choose "Generic Linux" instead of "Ubuntu" so you get a .tar.gz instead of .deb cd into the directory...
Like in any language, a FLOAT will eventually corrupt data due to rounding errors. Please use DECIMAL, which has well...
Be careful with the Active Record where method. When you accidentally pass an empty array to the where method using...
validates_uniqueness_of is not sufficient to ensure the uniqueness of a value. The reason for this is that in...
When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...
This Perl script will run diagnostics on your MySQL database and recommend changes to your MySQL configuration...
So you're switching to PostgreSQL from MySQL? Here is some help... General hints on PostgreSQL \? opens the command overview \d lists things: \du lists users, \dt lists tables etc...
...Command comparison Description MySQL command PostgreSQL equivalent Connect to the database mysql -u $USERNAME -p sudo -u postgres psql Show databases SHOW DATABASES; \l[ist] Use/Connect to a database named...
Note: For PostgreSQL you should use advisory locks. For MySQL we still recommend the solution in this card. If you need to synchronize multiple rails processes, you need some shared...
...can be used as a mutex. One option is to simply use your existing (MySQL) database. The attached code provides a database-based model level mutex for MySQL. You use...
In MySQL comparing zero to a string 0 = "any string" is always true! So when you want to compare a string with a value of an integer column, you have...
...knowing a secret token: Potential Query Manipulation with Common Rails Practises CVE-2013-3211 MySQL madness and Rails
CONCAT('foo', 'bar', NULL) = NULL the NULL always wins in MySQL. If you would rather treat NULL as an empty string, use CONCAT_WS (concatenation with separator) instead...
...want to see how long your database queries actually take, you need to disable MySQL's query cache. This can be done globally by logging into a database console, run...
ActiveRecord::Base.uncached do yield end true end Don't forget to re-enable MySQL query caching later with SET GLOBAL query_cache_type=ON...
I recently experienced the error ActiveRecord::StatementInvalid: Mysql2::Error: closed MySQL connection. Apparently this happens when there is a timeout during query execution. In order to fix this you can...
All TEMPORARY tables are closed (and dropped). ... For further details see the mysql doc. You can actually force this error by setting a short timeout and sleeping in...
For string columns, MySQL indexes the left side of a string. That means an index can speed a like query that has a wildcard on the right side:
Add a user without password (recommended) Replace newuser with your desired username: mysql -uroot -p CREATE USER 'newuser'@'localhost' IDENTIFIED BY ''; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES...
...by a password, you can remove the password. Replace existinguser with your desired username: mysql -uroot -p SET PASSWORD FOR existinguser@localhost=''; FLUSH PRIVILEGES; exit; Add a user with unix...
...lives in another table, you need to JOIN both tables during the UPDATE. In MySQL you can do it like this: UPDATE employees LEFT JOIN departments ON employees.department_id = departments.id...
To show the MySQL default character set you have to login to the MySQL console and execute SHOW VARIABLES LIKE 'char%'; mysql> SHOW VARIABLES LIKE 'char%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+
...to uft8 you have to add this default-character-set = utf8 to the client, mysqld_safe, mysqld and mysqldump section (may differ depending on configuration) in your my.cnf and restart...
...in different order. Solving deadlocks is potentially complicated, so here are a few pointers: MySQL should always detect the deadlock right when it happens, and will throw an error to...
...still cannot see what actually happened, you might need to get better acquainted with MySQLs locking model. While it keeps out of your way usually, it's actually pretty complex...
MySQL and MariaDB have an SQL mode setting which changes how MySQL behaves. The SQL mode value is comprised of multiple flags like "STRICT_TRANS_TABLES, NO_ZERO_IN_DATE...
...or disables a particular behavior. The default SQL mode varies widly between versions of MySQL and MariaDB. In general, more recent versions of MySQL and MariaDB have stricter settings than...