-
Archives
- January 2012
- December 2011
- September 2011
- August 2011
- June 2011
- January 2011
- December 2010
- November 2010
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- January 2009
- November 2008
- September 2008
- August 2008
- July 2008
- March 2008
- February 2008
- January 2008
-
Meta
Tag Archives: MySQL
mysqldump results to wrong characters
Try the following: $ mysqldump -u<user> -p dbsource tablein –where=”products_id >= 20000028 and products_id <= 25531404″ –default-character-set=UTF8 > dumpfile.sql $ mysql -u<user> -p dbtarget –default-character-set=UTF8 < dumpfile.sql
Restore MySQL Database using mysqlbinlog
1. Get log for database to restore $ mysqlbinlog –database=db_name mysql-bin.000001 > /tmp/db/restore.sql $ mysqlbinlog –database=db_name mysql-bin.000002 >> /tmp/db/restore.sql $ mysqlbinlog –database=db_name mysql-bin.000003 >> /tmp/db/restore.sql 2. Edit restore.sql 3. Execute SQL commands on restore.sql
selective mysqldump
$ mysqldump -uroot -p DB TBL –where=”COL_ID=3″ | grep INSERT
How to set a MySQL Table AUTO_INCREMENT
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this: mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;
How to Remove a MySQL Table constraint
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`) … Continue reading
How to Create Database and Add User To It
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;