IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » mysql The latest public mysql snipts.

showing 1-20 of 214 snipts for mysql
  • How to Dump All Databases in MySQL Server
    mysqldump -u username -ppassword –all-databases > dump.sql
    

    copy | embed

    0 comments - tagged in  posted by Navetz on Aug 31, 2010 at 10:35 p.m. EDT
  • mysql file into db
    mysql -p -h DBSERVER dbname < dbname.sql
    

    copy | embed

    0 comments - tagged in  posted by prauber on Aug 23, 2010 at 9:57 a.m. EDT
  • mysql dump into file
    mysqldump -u DBUSER -p DBNAME > DBNAME.sql
    

    copy | embed

    0 comments - tagged in  posted by prauber on Aug 23, 2010 at 9:57 a.m. EDT
  • Related users tables and views
    CREATE OR REPLACE VIEW #__foo_users AS
    SELECT u.*
    FROM jos_users AS u;
    
    
    CREATE TABLE IF NOT EXISTS `#__foo_barusers` (
      `foo_barusers_id` bigint(20) unsigned NOT NULL auto_increment,
      `foo_bar_id` bigint(20) unsigned NOT NULL,
      `user_id` bigint(20) unsigned NOT NULL,
      `created_on` datetime NOT NULL default '0000-00-00 00:00:00',
      `created_by` int(11) NOT NULL default 0,
      `modified_on` datetime NOT NULL default '0000-00-00 00:00:00',
      `modified_by` int(11) NOT NULL default 0,
      PRIMARY KEY ( `foo_barusers_id` )
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
    
    CREATE OR REPLACE VIEW #__foo_view_barusers AS 
    SELECT bu.*, 
    	b.name AS bar,
    	b.enabled AS bar_enabled, 
    	b.access AS bar_access,
    	u.name AS name,
    	u.username AS username,
    	u.email	AS	email,
    	u.usertype AS usertype
    FROM #__foo_barusers AS bu
    LEFT JOIN #__foo_bars AS b ON b.foo_bar_id = bu.foo_bar_id
    LEFT JOIN #__foo_users AS u ON u.id = mu.user_id;
    

    copy | embed

    0 comments - tagged in  posted by juanhm on Aug 23, 2010 at 5:19 a.m. EDT
  • Import CSV data into mysql table
    load data infile '/var/lib/mysql/your_db/yourcsv.csv' into table magento_orders
    fields terminated by ','
    enclosed by '"'
    lines terminated by '\n'
    // if csv exported from linux - use lines terminated by '\n'
    // if csv exported from windows use lines terminated by '\r\n'
    // if csv exported from mac - use lines terminated by '\r'
    (OrderDate,ShippingState,ShippingStateName,ShippingCountry,ShippingCountryName,ItemName,ItemOptions,ItemQtyOrdered)
    

    copy | embed

    1 comment - tagged in  posted by deric on Aug 18, 2010 at 3:34 p.m. EDT
  • Get Basic Product Info From Magento DB
    SELECT e.entity_id AS product_id, var.value AS product_name
    FROM catalog_product_entity e, eav_attribute eav, catalog_product_entity_varchar var
    WHERE 
       e.entity_type_id = eav.entity_type_id 
       AND eav.attribute_code = 'name' 
       AND eav.attribute_id = var.attribute_id
       AND var.entity_id = e.entity_id
    

    copy | embed

    0 comments - tagged in  posted by deric on Aug 18, 2010 at 1:13 p.m. EDT
  • MySQL update set
    UPDATE tblTransaction AS t LEFT JOIN tblEmployee as e
    ON e.emp_id = t.emp_id SET t.emp_block = e.emp_block 
    

    copy | embed

    0 comments - tagged in  posted by tayhimself on Aug 18, 2010 at 9:45 a.m. EDT
  • mysql - conexiones remotas en ubuntu
    Si quieres poder conectarte a MySQL desde una aplicación externa (como Navicat) en otra maquina hay que habilitar conexiones remotas.
    
    # 1. Hay que editar el archivo /etc/mysql/my.cnf
    
    sudo gedit /etc/mysql/my.cnf
    
    # 2. Ya en gedit buscamos con ctrl + F "bind-address" sin comillas
    # Comentamos la linea
    
     bind-address = 127.0.0.1
    
    # dejandola así:
    
    # bind-address = 127.0.0.1
    
    3. Guardamos el archivo y reiniciamos MySQL
    
    sudo restart mysql
    
    ----
    
    Listo, con eso podras conectarte a MySQL desde otra aplicación que no esté en el mismo servidor localmente.
    

    copy | embed

    0 comments - tagged in  posted by ecwpa on Aug 10, 2010 at 12:59 p.m. EDT
  • mysql backup
    mysqldump -u root -p --database db_name > ~/db_name.sql
    

    copy | embed

    0 comments - tagged in  posted by gotoplanb on Aug 09, 2010 at 11:04 p.m. EDT
  • copy a mysql database
    mysql -u root
    create database new_database; 
    ^D
    
    mysqldump -u root old_database | mysql -u root -D new_database
    

    copy | embed

    0 comments - tagged in  posted by febeling on Aug 05, 2010 at 9:48 a.m. EDT
  • MySQL global search & replace
    mysql -u user -ppassword -e "SELECT CONCAT('UPDATE ',table_schema,'.',table_name, ' SET ',column_name, '=REPLACE(',column_name,',''old_string'',''new_string'');') FROM information_schema.columns WHERE table_schema = 'database_name'" | sed '1d' | mysql -u user -ppassword database_name
    

    copy | embed

    0 comments - tagged in  posted by Andrei on Jul 31, 2010 at 1:13 p.m. EDT
  • delete magetno order
    SET @orderId = '200000001';
    
    SET FOREIGN_KEY_CHECKS = 1;
    
    DELETE FROM sales_flat_order
        WHERE increment_id = @orderId;
        
    DELETE FROM sales_flat_order_grid
        WHERE increment_id = @orderId;
    
    DELETE FROM sales_flat_quote
        WHERE reserved_order_id = @orderId;
    
    DELETE FROM sales_flat_shipment
        WHERE increment_id = @orderId;
    
    DELETE FROM sales_flat_shipment_grid
        WHERE order_increment_id = @orderId;
    
    DELETE from sales_flat_invoice
        WHERE increment_id = @orderId;
    
    DELETE from sales_flat_invoice_grid
        WHERE order_increment_id = @orderId; 
    

    copy | embed

    0 comments - tagged in  posted by danielnolan on Jul 30, 2010 at 4:27 p.m. EDT
  • create mysql user and grant privileges
    CREATE USER drupaluser;
    SET PASSWORD FOR drupaluser = PASSWORD(password);
    GRANT ALL PRIVILEGES ON drupal.* TO drupaluser@localhost IDENTIFIED BY password;
    

    copy | embed

    0 comments - tagged in  posted by lukasnick on Jul 27, 2010 at 10:24 a.m. EDT
  • wordpress plugin reset
    UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
    

    copy | embed

    0 comments - tagged in  posted by dsherratt on Jul 26, 2010 at 6:41 a.m. EDT
  • Magento: SQL filter by custom product attrib
    <?php
    
    // SQL call where custom product attrib 'promo' == 1
    
    $pcollection = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToSelect('*')
                //->addAttributeToFilter('sku',array('like' => '%ABC%'))
                ->addAttributeToFilter('promo', '1');
    foreach($pcollection as $pp)
    {
        // method 1
        $_promoProduct = $pp->_data;
    
        Zend_Debug::dump($_promoProduct); 
        die();
     
        // method 2
        $url = $pp->getProductUrl();
        $name = $this->htmlEscape($pp->getName());
        $img_src = $pp->getThumbnailUrl(325, 215);
        $price = number_format($pp->getPrice(), 2);
        // etc
    }
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Jul 23, 2010 at 9:54 p.m. EDT
  • drop all tables
    mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]
    

    copy | embed

    0 comments - tagged in  posted by jonbiddle on Jul 22, 2010 at 3:01 p.m. EDT
  • Change Wordpress Site URL and URL Home
    <?php
    if (!file_exists('wp-config.php')) exit('Could not find wp-config.php, please make sure you place this file in the same directory as all your WP files.');
    
    require 'wp-config.php';
    
    $link = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if (!$link) exit('Could not connect to MySQL');
    mysql_select_db(DB_NAME, $link) or exit('Could not connect to MySQL');
    
    if (mysql_query('UPDATE `' . $table_prefix . "options` SET `option_value` = 'NEW SITE URL HERE!!!' WHERE `option_name` = 'siteurl'", $link) . "' LIMIT 1", $link)) echo 'Step 1 - done';
    else echo 'Could not update: ' . mysql_error($link);
    if (mysql_query('UPDATE `' . $table_prefix . "options` SET `option_value` = 'NEW SITE URL HERE!!!' WHERE `option_name` = 'home'", $link) . "' LIMIT 1", $link)) echo 'Step 12- done';
    else echo 'Could not update: ' . mysql_error($link);
    
    mysql_close($link);
    ?>
    

    copy | embed

    1 comment - tagged in  posted by Jordan on Jul 08, 2010 at 4:47 p.m. EDT
  • Optimize all tables on MySQL database
    mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
    

    copy | embed

    0 comments - tagged in  posted by mdylanbell on Jun 24, 2010 at 6:25 a.m. EDT
  • Search for records between two dates
    SELECT * FROM tblModeratedComments WHERE dateCreated >= '2010-04-01' AND dateCreated < '2010-05-01'
    

    copy | embed

    0 comments - tagged in  posted by richard on Jun 01, 2010 at 6:58 a.m. EDT
  • Create new databases with UTF8 explicitly specified
    create database keystone default character set = 'utf8' \
       default collate = 'utf8_general_ci';
    

    copy | embed

    0 comments - tagged in  posted by shacker on May 25, 2010 at 3:43 p.m. EDT
Sign up to create your own snipts, or login.