shell-for stage_1 shell-for stage_2 Get the stage1 and stage2 MySQL credentials: cat /opt/www/the_stage.host.tld/current/config/database.yml cat config/database.yml # should do it Dump the table to a path reachable...
...by the stage2 user (e.g. home): mysqldump -h mysql1 -u stage_1_user -p stage_1_database table_name > ~/table_name_dump.mysql # Select certain records using --where "some_id > 666"
If you upgrade to the mysql2 gem, you will run into the problem that the server's database.yml (which is usually not under version control) needs to change exactly on...
You can however make your database.yml work for mysql and mysql2 at the same time. Simpy do this production: adapter: <%= defined?(Mysql2) ? 'mysql2' : 'mysql...
Unless all MySQL server defaults are set to UTF-8, mysqldump encodes UTF-8 characters incorrectly and only outputs correct UTF-8 when you switch to Latin 1 (!). Also you...
...for each new database. To prevent this, make sure your /etc/mysql/my.cnf looks like this: [mysqld] default-character-set = utf8mb4 collation-server = utf8mb4_unicode_ci [mysql] default-character-set=utf8mb4
On some of our older projects, we use the mysql2 gem. Unfortunately, versions 0.2.x (required for Rails 2.3) and versions 0.3.x (required for Rails 3.2) can no longer...
...when compiling the native extension, or a segfaults when using it. For Rails 4.2, mysql2 version 0.4.10 seems to work okay. If you still have issues, upgrade to 0.5.x...
So you got this error, even though your Gemfile bundles mysql2: !!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2' or Please install the mysql adapter: `gem install...
...activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) The reason for this confusing error message is probably that your Gemfile says mysql2, but your...
...when importing. Dumping safely # Do not do this, since it might screw up encoding mysqldump -uroot -p database > utf8.dump # this is bad Better do: mysqldump -uroot -p database -r utf8.dump
...Note that when your MySQL server is not set to UTF-8 you need to do mysqldump --default-character-set=latin1 (!) to get a correctly encoded dump. In that case...
MySQL version 5.1 comes with an alternative, faster InnoDB implementation (called "InnoDB Plugin"). Switching is easy: Stop your mysqld with sudo stop mysql Add the following lines to your /etc/mysql/my.cnf...
...under the [mysqld] section ignore-builtin-innodb plugin-load=innodb=ha_innodb_plugin.so Start your mysqld with sudo start mysql The file format has not changed, your tables should survive this.
...hosts non-critical development data and only you have access to, you can store MySQL's root password in your home directory so you can use mysql commands without prompt...
user=root password=YOURMYSQLROOTPASSWORDHERE EOF Now you should be able to just type mysql and be logged in as MySQL's root user. This works for different MySQL commands...
mysql> SELECT @@global.version; +------------------+ | @@global.version | +------------------+ | 5.6.30 | +------------------+ 1 row in set (0,00 sec) MySQL 5.6 Reference Manual says "BLOB and TEXT columns cannot have DEFAULT values". If you want to run...
...and stash you changes in the migration files. 2. Temporally change the sql mode mysql> SELECT @@global.sql_mode; +--------------------------------------------+ | @@global.sql_mode | +--------------------------------------------+ | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | +--------------------------------------------+
Look here for informations how you can show the MySQL default character set. At first you need the Amazon RDS Command Line Toolkit download and unzip the Amazon RDS Command...
After that you can create a new parameter group /home/foobar/Downloads/RDSCli-1.4.007/bin/rds-create-db-parameter-group utf8 -f mysql5.1 -d "default parameter with utf8" --aws-credential-file ./aws-credential.txt --region eu-west-1
...and their data, under a new name. Make a dump of your source database: mysqldump -uroot -p my_project -r my_project.sql Or, if you only want to dump the database...
...s table structure (schema) without any contents: mysqldump -uroot -p my_project -r my_project.sql --no-data Open up a MySQL shell: mysql -uroot -p From the MySQL shell, create a...
...itself did not work for me. Uninstall everything related to MySQL 5.7 with apt remove mysql-client mysql-server libmysqlclient-dev mysql-common Check if you removed everything using
...MySQL 5.6" and "Ubuntu Wily" (assuming Xenial is not yet provided) Run apt-cache policy mysql-server If this shows a 5.6 version, continue. If not, check your /etc/apt/sources.list.d/mysql.list. It...
The result might look like this: +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000001 | 1219 | | | +------------------+----------+--------------+------------------+ Dump the database (in a new terminal): mysqldump -uroot -p -r...
...HOST='127.0.0.1', MASTER_PORT=3307, MASTER_USER='replicator', MASTER_PASSWORD='some_password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=1219; MASTER_HOST and MASTER_PORT are set to...
When using GROUP BY, MySQL now complains if the SELECT includes columns which are not part of the GROUP BY. Reason: There could be multiple values for those columns per...
Also see our card on SQL compatibility modes. Install MySQL 5.6 in parallel, using mysql-sandbox Use MariaDB 10.x What TRADITIONAL changes MySQL 5.7 standard TRADITIONAL
Stop MySQL: sudo service mysql stop Move (or copy) your mysql directory. If you want /mnt/mysql to be the new directory, do it like this:
.../var/lib/mysql /mnt/ Open your MySQL configuration (sudo vim /etc/mysql/my.cnf) and change the datadir value to your new path (e.g. /mnt/mysql) Modify your AppArmor configuration: sudo vim /etc/apparmor.d/usr.sbin.mysqld Change/copy the lines...
This will make MySQL log all received queries so you can see for yourself what happens on the database level. Don't switch this on for production machines!
sudo vim /etc/mysql/my.cnf In the [mysqld] section, add: log=/var/log/mysql.log Restart your MySQL daemon. On Ubuntu: sudo service mysql restart Note that your MySQL performance will suffer. But when...
...COUNT(DISTINCT #{field}) AS count") end Although the given variable is sanitized here, the MySQLAdapter's (and probably other adapters as well) method for this is insufficient as it only...
...query will look like this: SELECT COUNT(DISTINCT `id); DELETE FROM users; -- `) AS count; MySQL will complain about a missing column '`id); DELETE FROM users; -- `' which is safe.
...data. Dumping single tables makes sense if a complete dump would be to big. mysqldump -u deploy_user -p application_production table1 table2 table2 > table1_table2_table2.sql.dump Hint: If a table has...
...be more handy. Further reading: - How to load only a subset of a massive MySQL dump - How to import production database dump to staging (or the other way...
If you have many connections to your MySQL or MariaDB (as we have) you might want to filter the list you see when running a SHOW PROCESSLIST. To hide all...
There is an more advanced way by querying the information_schema database: Show MySQL process list without sleeping connections
ALTER DATABASE database_name CHARACTER SET "utf8"; ALTER DATABASE database_name COLLATE "utf8_unicode_ci"; After that, for...
...create an int column, which is smaller than a bigint. These are values for MySQL. At least on PostgreSQL you can just use bigint instead of integer: create_table :example...
...some deliberation, we decided to implement a "schema-less" storage system on top of MySQL rather than use a completely new storage system. This post attempts to describe the high...
Store schema-less data in MySQL...
MMM (MySQL Master-Master Replication Manager) is a set of flexible scripts to perform monitoring/failover and management of MySQL Master-Master replication configurations (with only one node writable at any...