Posted almost 9 years ago by Arne Hartherz.

...on the server (ls -l). In our case, it's 1234567890. Know your (local) MySQL root password. We'll use SECRET below. Know your (local) target database name. For us...

...my_project_development. Go wild: ssh user@example.com "cat /mnt/dumps/my_project.dump.bz2" | pv -s 1234567890 | bzip2 -d | mysql -uroot -pSECRET my_project_development That will: Print the (bzipped) file to stdout on the...

Posted almost 8 years ago by Tobias Kraze.

...of does not consider "username" and "USERNAME" to be a collision. If you use MySQL this will lead to issues, since string comparisons are case-insensitive in MySQL.

...sensitive => false end When you get an ActiveRecord::RecordNotUnique error (probably in combination with Mysql2::Error: Duplicate entry) for a string field, case sensitivity may be your issue...

Posted over 7 years ago by Henning Koch.

We upgraded a Rails 2 application to Rails 3.2 and Ruby 2.1, changed the mysql adapter from mysql to mysql2, but did not activitate the asset pipeline. Instead we used...

Posted 11 months ago by Dominik Schöler.

...that checks out a feature branch based on a story from Pivotal Tracker Faster MySQL dumping with --single-transaction and --quick Allow pivotal tracker ids in the global config file...

Posted almost 2 years ago by Henning Koch.

...will make a single query. It uses a sub-query, which is slow in MySQL, but fast in PostgreSQL: SELECT * FROM posts WHERE user_id IN (SELECT id FROM users...

Posted about 6 years ago by Martin Straub.

...ruby-debug and use e.g. byebug Remove gem oniguruma Remove gem fastercsv Replace gem mysql with mysql2 Update gem capistrano 2.12.0 to ~>2.12 when bound for Ruby 1.8.7 and remove...

Posted over 6 years ago by Emanuel De.

...foreign keys. They are dumped to schema.rb as well. At this time, only the mysql, mysql2 and postgresql adapters support foreign keys. @rubyonrails Workings add_foreign_key(:comments, :users)

Posted over 2 years ago by Dominik Schöler.

...public | pages | 3919 Please note that this does not work reliably on database slaves. MySQL SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = (SELECT database()) ORDER BY table...

Posted over 2 years ago by Stefan Langenmaier.

MariaDB (and MySQL) is released in different versions with different behaviors. For backwards compatibility this can be managed with the sql_mode option. Following you can find behavior differences which...

Posted over 3 years ago by Emanuel De.

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...

Posted almost 4 years ago by Natalie Zeumann.

...sum up columns with + in a sql-query if NULL-Values can be present. MySQL and PostgreSQL cannot sum up NULL values with the + value. The sum value will be...

MySQL: mysql> select 1 + 2 + 3; +-----------+ | 1 + 2 + 3 | +-----------+ | 6 | +-----------+ 1 row in set (0,00 sec) mysql> select 1 + NULL + 3; +--------------+ | 1 + NULL + 3 | +--------------+ | NULL | +--------------+

Posted almost 7 years ago by Henning Koch.

...when committing a transaction. E.g. you might see an error like this: ActiveRecord::StatementInvalid: Mysql::Error: Lock wait timeout exceeded; try restarting transaction This has nothing to do with the...

...application-level locks that we talk about below. What happens here is that when MySQL makes changes, it locks rows in the database to ensure that the change will applied...

Posted over 10 years ago by Henning Koch.

...in a DECIMAL field, and that number exceeds that column's precision or scale MySQL (strict mode) The database connection will throw an error. MySQL (no strict mode)

...These changes are performed inside MySQL. Note that when you loaded an ActiveRecord model with a DECIMAL column, and you assign an exceeding number to the respective record attribute, you...

Posted almost 5 years ago by Kim Jahn.

If you have a replication error with MySQL and you know the "error" is okay (e.g. you've executed the same statement at the same time on 2 masters which...

...your second statement is really the next one which would get executed by the MySQL server. Example: you've executed drop database foobar; and drop database blubber; in a row...

Posted about 3 years ago by Dominik Schöler.

...suffer from reduced performance. Check the table size by consumed disk space in PostgreSQL / MySQL/MariaDB, or by row count. Check storage usage Just like database tables, storage usage may increase...

Posted over 10 years ago by Henning Koch.

...note that while this note has a number of code examples in Ruby and MySQL, the concepts apply to all programming languages and data stores. When to round

...of rounded values. Don't ever use the float data type in Ruby or MySQL The data types Float (Ruby) and FLOAT (MySQL) are not suited for calculating or storing...

Posted almost 9 years ago by Henning Koch.

...of you should always have a unique key constraint on the column in your MySQL. E.g. when you are validating the uniqueness of usernames, the users#screen_name column should...

...have a unique MySQL index. Using unique key constraints give you a hard guarantee for the uniqueness of your values. The race condition as detailed above can no longer occur...

Posted over 5 years ago by Tobias Kraze.

This error can be caused by the mysql2 gem under mysterious circumstances. You need to remove it with gem uninstall mysql2 and then reinstall it (or just run bundle).

...pristine mysql2 will not be enough...

This website uses short-lived cookies to improve usability.
Accept or learn more