Archive for the ‘SQL’ Category

How to Remove a MySQL Table constraint

Tuesday, August 26th, 2008

ALTER TABLE `attributes` DROP FOREIGN KEY `attributes_ibfk_1`;

MySQL ERROR 1005 (HY000): Can’t create table ‘Table.frm’ (errno: 150).  Here’s the solution.

Example:
ALTER TABLE `race` DROP FOREIGN KEY `race_ibfk_1`;

ALTER TABLE `race`
ADD CONSTRAINT `race_ibfk_1` FOREIGN KEY (`specieId`) REFERENCES `specie` (`specieId`) ON DELETE CASCADE;

How to Create Database and Add User To It

Friday, July 25th, 2008

Here are the SQL commands:

create database newdb;

grant CREATE,INSERT,DELETE,UPDATE,SELECT on newdb.* to newuser@localhost;

SET PASSWORD FOR 'newuser'@'localhost' = password(’newuserpass’);
– or –
SET PASSWORD FOR 'newuser'@'localhost' = old_password(’newuserpass’);

flush privileges;