Quickies

[categories] [index] [all (531)] [latest]

MySQL
  1. mysql> ALTER TABLE my_table ADD FULLTEXT(my_col);
    

    This doesn't work on InnoDB tables, but only on MyIsam ones.

    SELECT *
    FROM my_table
    WHERE MATCH (my_col)
    AGAINST('my_text');
    
  2. mysql> ALTER TABLE nm_newsitem ADD CONSTRAINT unique_link UNIQUE (link(255));
    
  3. mysql> ALTER TABLE my_table ADD INDEX(my_col);
    
  4. mysql> ANALYZE TABLE my_table;
    
  5. mysql> USE my_db;
    
  6. $ mysql -u user_name -p
    
  7. mysql> DESCRIBE my_table;
    
  8. mysql> SHOW TABLES;
    
  9. $ mysqldump --opt --user=username --password database > dumpfile.sql
    
    $ mysqldump --user my_user --password=my_password database > dumpfile.sql
    
  10. $ mysqldump --no-data --opt --user=root --password news_memory > tables.sql
    
  11. $ mysql --user=username --password database < dumpfile.sql
    
  12. mysql> INSERT INTO my_table VALUES ('','France','fr');
    
  13. $ /usr/local/mysql/bin/mysqladmin -u root password xxxxxxxx
    
  14. mysql> UPDATE my_table SET my_table.my_row_1 = 'Lausanne' WHERE my_table.my_row_2 = 2338;
    
  15. mysql> OPTIMIZE TABLE my_table;
    
  16. ALTER TABLE my_table AUTO_INCREMENT=1;
    

    The value is the one that will be used next.

  17. update <table> set <champ> = replace(<champ>,'<avant>','<apres>');
    
  18. $ sudo mysqld_safe --user=root &
    
  19. $ mysqladmin -u root --password=xxxxxxxx shutdown
    
  20. Since version 4.1, MySQL stores password in a new way.

    Previous clients can't authenticate anymore.

    As a workaround, you can update user passwords in mysql.user table:

    mysql> UPDATE mysql.user SET password = OLD_PASSWORD('password') WHERE user = 'xxx' and host = 'xxx';
    mysql> FLUSH PRIVILEGES;
    
  21. Since MySQL 4.1 :

    mysql> ALTER TABLE ma_table MODIFY ma_colonne CHAR(150) CHARACTER SET utf8;