SET PASSWORD FOR 'bob'@'%.example.org' = PASSWORD('cleartext password');
Count number of records in array: db.data_records.count( { dataset_id: { $in: [ 2509, 2224, 2128, 2145, 2472, 2249 ] } } ) Count number of records...
ActiveRecord::Schema.define do <> end
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
SELECT table_schema 'DB Name', round(Sum(data_length + index_length) / 1024 / 1024, 1) 'DB size in MB' FROM information_schema.tables...
bundle exec sidekiq -e staging -d -L log/sidekiq.log sidekiq -h -c, –concurrency INT processor threads to use -d, –daemon Daemonize...
mysql>CREATE DATABASE memcachedSample; mysql>CREATE USER 'web20'@'localhost' IDENTIFIED BY 'web20'; mysql>GRANT ALL PRIVILEGES ON memcachedSample.* TO 'web20...
drop index index_name on table_name
c = ActiveRecord::Base.connection c.tables.collect do |t| columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id" || x.ends_with("_type"))}
SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = "databaseName" AND TABLE_NAME = "tableName" alter table tablename auto_increment = newvalue
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
Best results in other decks
Short reference on how to quickly debug the vanilla Rails job adapters. Queue Adapters by Environment Environment Adapter
Sometimes you have a maintenance script where you want to iterate over all ActiveRecord models. Rails provides this out of...