MySQL behaviour you should be aware of

I suggest changing the syntax for NOT NULL to “NOT” NULL. If you’re not checking all values in your code logic (viz. PHP code or something like that) before attempting to perform the database manipulation you can fix it by (manually) add triggers to your tables to actually prevent a faulty insert/update: mysql> CREATE TRIGGER …

Storing MD5 values

A common occurrence I have noticed in MySQL apps is that MD5 values are stored as 32 byte values rather than 16. Just to ‘rehash’, an MD5 value is a 16 byte hexadecimal value, typically used as a unique fixed-length signature of a string, useful for identifying unique strings or one-way encryption of passwords. The …

WebScaleSQL

WebScaleSQL is a collaboration among engineers from several companies that face similar challenges in running MySQL at scale, and seek greater performance from a database technology tailored for their needs. Those “several companies” are Facebook, Google, LinkedIn, and Twitter. And the collaboration mentioned is a true collaboration: For example, to introduce a code change, a …

Backup local MySQL Databases

Nice script by Xavez. Put it in a daily cronjob if you like, or extend it to copy the backup to another machine: #!/bin/bash # Path to where you want to backup mysql databases. opath=/Users/username/Sites/Backups/mysql/ # Local mysql details. Make a username with only read access. Allow SELECT, LOCK TABLES. mysqlhost=127.0.0.1 username=read_only_user password=read_only_password # Get …

node-orm2 — Node.js Object Relational Mapping

ORM Package for Node.js. Works with MySQL, PostgreSQL and SQLite. var orm = require(‘orm’); orm.connect("mysql://username:password@host/database", function (err, db) { if (err) throw err; var Person = db.define(‘person’, { name : String, surname : String, age : Number, male : Boolean, continent : [ ‘Europe’, ‘America’, ‘Asia’, ‘Africa’, ‘Australia’, ‘Antartica’ ], // ENUM type photo : …

MySQL: Get next AUTO_INCREMENT value from/for table

Note to self: To get the next auto_increment value from a table run this query: SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = "databaseName" AND TABLE_NAME = "tableName" Don’t forget it (again). Did this help you out? Like what you see?Consider donating. I don’t run ads on my blog nor do I do this for profit. …