Thursday, April 10, 2008

MySQL survival kit





  • To start it:
    C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin>mysqld-nt.exe
    You can also start it as a service
    On Vista, the db file is:
    C:\ProgramData\MySQL\MySQL Server 5.1\data\ibdata1
  • To see the tables:
    mysql -u root
    > use mysql
    > show tables

    > CREATE TABLE cumul_bench (
    id int(11) NOT NULL auto_increment,
    test_desc varchar(100) default '',
    tstamp datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (id)
    ) TYPE=MyISAM;

    > show tables

    > SHOW COLUMNS FROM cumul_bench
  • regex in mysql


  • WHERE cat_id REGEXP '^10.{6}$'    (start with a 10, followed by 6 digits)


    • Enable query log  in  /etc/mysql/my.cnf   (affects performances)
      • [mysqld]
      • general_log      = on
      • general_log_file = /var/log/mysql/query.log

    •  

    No comments: