Tags: MySQL

Sort by: Date / Title /

  1. 1 week ago by bobuse
    1. DELETE sc_bookmarks,
    2. sc_tags FROM sc_tags,
    3. sc_bookmarks WHERE sc_tags.bId = sc_bookmarks.bId AND sc_tags.tag = "tag_des_signets_à_supprimer"
  2. 3 weeks ago by rosy1280
    command to determine the version of mysql optionally you can run the command without the -h
    1. mysql -h <hostname> -V
  3. 1 month ago by sx
    1. DATUM=`date '+%Y-%m-%d'`
    2. mysqldump -u USER --password=PASSWORD DATABASE TABLE > /home/backup/db.sql
    3. gzip /home/backup/db.sql
    4. mv /home/backup/db.sql.gz /home/backup/db-${DATUM}.sql.gz
    5. find /home/backup/ -mtime +2 -type f -print0 | xargs -0 rm
  4. 1 month ago by spirit
    By default, MySQL's datadir is placed in the /var/lib/mysql directory. However, if you are planning on using MySQL tables to store a lot of data and your /var partition is small, it might cause you problem at a later stage. In such a scenario, it is better to move the MySQL's datadir to another partition
    Steps:
       1. Stop your mysql server before starting this operation
       2. Create the directories that will be new datadir
       3. chown the directory to the mysql:mysql user
       4. copy the files from the old datadir to the new location (cp -p : preserves ownership). However, make sure that the files
           named ib_arch_log_0000000000, ib_logfile0 etc. are not copied to the newer location
       5. Make sure that the files and directories are owned by mysql user
       6. Make changes in the my.cnf to point the new datadir (datadir = /my/new/dir/)
       7. Restart the MySQL database
       8. Create a new database and verify that the files for this database are getting created in the new datadir (create database test)
       9. After the server is running for a few days properly, get rid of the old data.
  5. 1 month ago by spirit
    1. # If you have never set a root password for MySQL
    2. mysqladmin -u root password MYPASS
    3.  
    4. # if you want to change (or update) a user password
    5. mysqladmin -u MYUSER -p OLDPASS NEWPASS
  6. 5 months ago by grummfy
    #Param #HOST : host of your database : localhost, sql.free.fr, .... #DATABASE : your database name #FILE.sql : the file to restore #USERNAME : your username access
    mysql -D DATABASE -u USERNAME -p -h HOST --default-character-set=utf8 < FILE.sql
  7. 5 months ago by spirit
    1. # MySQL has 2 methods for handling this:
    2.  
    3. REPLACE INTO people(id,name,email) VALUES (in_id, in_name, in_email);
    4.  
    5. INSERT INTO people(id,name,email) VALUES (in_id, in_name, in_email) ON DUPLICATE KEY UPDATE name='$in_name', email='$in_email';
  8. sponsorised links
  9. 6 months ago by cyo and saved by 1 other
    1. mysqldump --add-drop-table -uroot -p NOM_DE_LA_BASE  | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -uroot -p NOM_DE_LA_BASE
  10. 6 months ago by spirit
    1) mysqladmin extended (absolute values)
    
    The values making most sense to monitor are:
    * Slave_running: If the system is a slave replication server, this is an indication of the slave's health.
    * Threads_connected: The number of clients currrently connected. This should be less than some preset value (like 200), but you can also monitor that it is larger than some value to ensure that clients are active.
    * Threads_running: If the database is overloaded you'll get an increased number of queries running. That also should be less than some preset value (20?). It is OK to have values over the limit for very short times. Then you can monitor some other values, when the Threads_running was more than the preset value and when it did not fall back in 5 seconds.
    
    2) mysqladmin extended (counters)
    The idea is that you store the performance counter value and compute the difference with the new values. The interval between the recordings should be more than 10 seconds. The following values are good candidates for checking:
    
    * Aborted_clients: The number of clients that were aborted (because they did not properly close the connection to the MySQL server). For some applications this can be OK, but for some other applications you might want to track the value, as aborted connects may indicate some sort of application failure.
    * Questions: Number of queries you get per second. Also, it's total queries, not number per second. To get number per second, you must divide Questions by Uptime.
    * Handler_*: If you want to monitor low-level database load, these are good values to track. If the value of Handler_read_rnd_next is abnormal relative to the value that you normally would expect, it may indicate some optimization or index problems. Handler_rollback will show the number of queries that have been rolled back. You might want to wish to investigate them.
    * Opened_tables: Number of table cache misses. If the value is large, you probably need to increase table_cache. Typically you would want this to be less than 1 or 2 opened tables per second.
    * Select_full_join: Joins performed without keys. This should be zero. This is a good way to catch development errors, as just a few such queries can degrease the system's performance.
    * Select_scan: Number of queries that performed a full table scan. In some cases these are OK but their ratio to all queries should be constant. if you have the value growing it can be a problem with the optimizer, lack of indexes or some other problem
    * Slow_queries: Number of queries longer than --long-query-time or that are not using indexes. These should be a small fraction of all queries. If it grows, the system will have performance problems.
    * Threads_created: This should be low. Higher values may mean that you need to increase the value of thread_cache or you have the amount of connections increasing, which also indicates a potential problem.
  11. 6 months ago by skanx
    Lock a database:
    $ mysql -u user -p
    mysql> FLUSH TABLES WITH READ LOCK;
    This closes all open tables and locks all tables for all databases with a read lock until you execute UNLOCK TABLES.
    
    Unlock:
    mysql> UNLOCK TABLES;
    
    (to lock a single table: LOCK TABLES table READ;)

First / Previous / Next / Last / Page 1 of 3 (30 posteets)