<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
    <title>Posteet: mysql</title> 
    <link>http://www.posteet.com/</link> 
    <description>Recent posteets posted to Posteet</description>
    <ttl>60</ttl>

    
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/posteet_mysql" /><feedburner:info uri="posteet_mysql" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
        <title>Resetting a forgotten MySQL root password</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/PKI7ovjhiG0/2126</link>
        <description>
        <![CDATA[<pre>First of all you will need to ensure that your database is stopped:

root@steve:~# /etc/init.d/mysql stop

Now you should start up the database in the background, via the mysqld_safe command:

root@steve:~# /usr/bin/mysqld_safe --skip-grant-tables &amp;
[1] 6702
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started

Here you can see the new job (number &quot;1&quot;) has started and the server is running with the process ID (PID) of 6702.

Now that the server is running with the --skip-grant-tables flag you can connect to it without a password and complete the job:

root@steve:~$ mysql --user=root mysql
Enter password:

mysql&gt; update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql&gt; flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql&gt; exit
Bye

Now that you've done that you just need to stop the server, so that you can go back to running a secure MySQL server with password restrictions in place. First of all bring the server you started into the foreground by typing &quot;fg&quot;, then kill it by pressing &quot;Ctrl+c&quot; afterwards.

This will now allow you to start the server:

root@steve:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

Now everything should be done and you should have regained access to your MySQL database(s); you should verify this by connecting with your new password:

root@steve:~# mysql --user=root --pass=new-password-here
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 5 to server version: 5.0.24a-Debian_4-log

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql&gt; exit
Bye</pre> <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/password">[password]</a> ]]>        </description>
        <dc:creator>sox</dc:creator>
        <pubDate>Sun, 27 Mar 2011 13:04:08 +0200</pubDate>

            <category>mysql</category>
            <category>password</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2126</feedburner:origLink></item>

  
    <item>
        <title>MySQL permissions for backup</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/x_T-CALR5_c/2082</link>
        <description>
        <![CDATA[<pre>GRANT SHOW DATABASES, SELECT, LOCK TABLES, RELOAD ON *.* to backup@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;</pre> <a href="http://www.posteet.com/tags/backups">[backups]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/readonly">[readonly]</a>  <a href="http://www.posteet.com/tags/security">[security]</a>  <a href="http://www.posteet.com/tags/user">[user]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Sat, 19 Jun 2010 18:21:25 +0200</pubDate>

            <category>backups</category>
            <category>mysql</category>
            <category>readonly</category>
            <category>security</category>
            <category>user</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2082</feedburner:origLink></item>

  
    <item>
        <title>query - case sensitive en mysql</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/McQ8NwSZAsc/2078</link>
        <description>
        <![CDATA[<pre>SELECT *  FROM `table`  WHERE BINARY `column` = 'value'</pre> <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Fri, 28 May 2010 17:44:37 +0200</pubDate>

            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2078</feedburner:origLink></item>

  
    <item>
        <title>mysql - guardar los resultados en un fichero</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/ioYL8vVLdF0/2074</link>
        <description>
        <![CDATA[<pre>SELECT id,title INTO OUTFILE &quot;c:/result.text&quot;
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '&quot;'
LINES TERMINATED BY &quot;n&quot;
FROM property;</pre> <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/querys">[querys]</a>  <a href="http://www.posteet.com/tags/tips">[tips]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Wed, 05 May 2010 00:44:05 +0200</pubDate>

            <category>mysql</category>
            <category>querys</category>
            <category>tips</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2074</feedburner:origLink></item>

  
    <item>
        <title>Restorer plus rapidement un dump MySQL (multi core)</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/XJF0cRoRrcA/2071</link>
        <description>
        <![CDATA[<pre>find -print0 | xargs -0 -n 1 -P 4 -I {} sh -c &quot;zcat '{}' | mysql mydatabase&quot;</pre> <a href="http://www.posteet.com/tags/backups">[backups]</a>  <a href="http://www.posteet.com/tags/find">[find]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/performances">[performances]</a>  <a href="http://www.posteet.com/tags/restore">[restore]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Sat, 24 Apr 2010 01:58:27 +0200</pubDate>

            <category>backups</category>
            <category>find</category>
            <category>mysql</category>
            <category>performances</category>
            <category>restore</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2071</feedburner:origLink></item>

  
    <item>
        <title>non-interactive mysql install on Debian / Ubuntu</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/BnCaJDH1ge0/2060</link>
        <description>
        <![CDATA[<pre>echo mysql-server mysql-server/root_password select PASSWORD | debconf-set-selections
echo mysql-server mysql-server/root_password_again select PASSWORD | debconf-set-selections

aptitude -y install mysql-server libmysqlclient15-dev</pre> <a href="http://www.posteet.com/tags/automatic">[automatic]</a>  <a href="http://www.posteet.com/tags/debian">[debian]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/non-interactive">[non-interactive]</a>  <a href="http://www.posteet.com/tags/script">[script]</a>  <a href="http://www.posteet.com/tags/shell">[shell]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Mon, 22 Mar 2010 23:49:11 +0100</pubDate>

            <category>automatic</category>
            <category>debian</category>
            <category>mysql</category>
            <category>non-interactive</category>
            <category>script</category>
            <category>shell</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2060</feedburner:origLink></item>

  
    <item>
        <title>manipular datos de una bd externa con django</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/Cw3cvfsAnD4/2056</link>
        <description>
        <![CDATA[<pre>from django.db import load_backend, transaction, connection

#manipular datos de una bd externa

def sincronizeDB(self):
        myBackend = load_backend('mysql') # or 'mysql', 'sqlite3', 'oracle'
        myConnection = myBackend.DatabaseWrapper({
            'DATABASE_HOST': '192.168.1.11',
            'DATABASE_NAME': 'agenciaperu_local',
            'DATABASE_OPTIONS': {},
            'DATABASE_PASSWORD': &quot;&quot;,
            'DATABASE_PORT': &quot;&quot;,
            'DATABASE_USER': &quot;root&quot;,})
        # Now we can do all the standard raw sql stuff with myConnection.
        myCursor = myConnection.cursor()        
        id = 22
        name = &quot;tecnologia para jos&quot;
        slug = &quot;tecnologia_para_jos&quot;
        row = myCursor.execute(&quot;INSERT INTO category(name, slug )  values(%s,%s);&quot;, [name, slug])
        row = myConnection._commit()
        #row = transaction.rollback_unless_managed()  -----&gt; sería cuando trabajamos en local

# select simple
        #row = myCursor.execute(&quot;select *from category where id = %s and highlight = %s;&quot;,[id,0])
        myCursor.fetchall()</pre> <a href="http://www.posteet.com/tags/django">[django]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a>  <a href="http://www.posteet.com/tags/python">[python]</a>  <a href="http://www.posteet.com/tags/soluciones">[soluciones]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Thu, 04 Mar 2010 21:19:49 +0100</pubDate>

            <category>django</category>
            <category>mysql</category>
            <category>python</category>
            <category>soluciones</category>
    
    <feedburner:origLink>http://www.posteet.com/view/2056</feedburner:origLink></item>

  
    <item>
        <title>ver la version mysql</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/Zaly4LIgGao/1787</link>
        <description>
        <![CDATA[<pre>#terminal
C:\&gt;mysql -uroot -p
mysql&gt; select version();

# cliente mysql
select version();</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Thu, 20 Aug 2009 00:30:39 +0200</pubDate>

            <category>bash</category>
            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1787</feedburner:origLink></item>

  
    <item>
        <title>agregar una columna a una tabla de la BD</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/MpaaTvc1CLk/1780</link>
        <description>
        <![CDATA[<pre>alter table media add column  status varchar (20) after component</pre> <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Thu, 13 Aug 2009 23:56:23 +0200</pubDate>

            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1780</feedburner:origLink></item>

  
    <item>
        <title>dump y restaurar base de datos - Mysql</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/c9qL9v9mvZQ/1775</link>
        <description>
        <![CDATA[<pre>#dump
mysqldump -hlocalhost -uuser -ppassword nomdatabase&gt; nomdatabase.sql

#restore
mysql -hlocalhost -uuser -ppassword nomdatabase &lt; nomdatabase</pre> <a href="http://www.posteet.com/tags/bash">[bash]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Tue, 11 Aug 2009 07:10:48 +0200</pubDate>

            <category>bash</category>
            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1775</feedburner:origLink></item>

  
    <item>
        <title>obtener la diferencia entre 2 fechas - Mysql</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/tk5fxUVPv_8/1772</link>
        <description>
        <![CDATA[<pre>SELECT TIMESTAMPDIFF(DAY,'2005-01-02','2006-01-08');</pre> <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>macks</dc:creator>
        <pubDate>Fri, 07 Aug 2009 23:55:48 +0200</pubDate>

            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1772</feedburner:origLink></item>

  
    <item>
        <title>Backup d'une database MySQL</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/bSMgNMnwVDk/1761</link>
        <description>
        <![CDATA[<pre>mysqldump -h localhost -u user -ppassword -r/tmp/mysql_backup.data nomdatabase

mysql -h localhost -u user -ppassword nomdatabase &lt; /tmp/mysql_backup.data</pre> <a href="http://www.posteet.com/tags/backup">[backup]</a>  <a href="http://www.posteet.com/tags/MySQL">[MySQL]</a> ]]>        </description>
        <dc:creator>benoitbalon</dc:creator>
        <pubDate>Mon, 27 Jul 2009 19:19:18 +0200</pubDate>

            <category>backup</category>
            <category>MySQL</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1761</feedburner:origLink></item>

  
    <item>
        <title>Pour lister les bases de données sur un serveur</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/LChD-f3uR6s/1693</link>
        <description>
        <![CDATA[<pre>mysql -u root -p
mysql&gt; show databases;</pre> <a href="http://www.posteet.com/tags/liste">[liste]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Wed, 06 May 2009 11:58:01 +0200</pubDate>

            <category>liste</category>
            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1693</feedburner:origLink></item>

  
    <item>
        <title>Pour optenir des infos sur une base de données en ligne de commande (notamment l'encodage utilisé)</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/xKhvL_Y5x-U/1692</link>
        <description>
        <![CDATA[<pre>mysql -u root -p -D nom_de_la_base
mysql&gt; status;</pre> <a href="http://www.posteet.com/tags/encodage">[encodage]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>cyo</dc:creator>
        <pubDate>Wed, 06 May 2009 11:56:23 +0200</pubDate>

            <category>encodage</category>
            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1692</feedburner:origLink></item>

  
    <item>
        <title>Distance between two points (given the latitude/longitude of those points) FUNCTION for MySQL</title>
        <link>http://feedproxy.google.com/~r/posteet_mysql/~3/LK_p-KVBJQ8/1555</link>
        <description>
        <![CDATA[<pre>Great circle distance
Find the distance in kilometres between two points on the surface of the earth. This is just the sort of problem stored functions were made for. For a first order approximation, ignore deviations of the earth's surface from the perfectly spherical. Then the distance in radians is given by a number of trigonometric formulas. ACOS and COS behave reasonably:

             COS(lat1-lat2)*(1+COS(lon1-lon2)) - COS(lat1+lat2)*(1-COS(lon1-lon2))
rads = ACOS( --------------------------------------------------------------------- )
                                              2

We need to convert degrees latitude and longitude to radians, and we need to know the length in km of one radian on the earth's surface, which is 6378.388. The function:

set log_bin_trust_function_creators=TRUE;

DROP FUNCTION IF EXISTS GeoDistKM;
DELIMITER |
CREATE FUNCTION GeoDistKM( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS float
BEGIN
  DECLARE pi, q1, q2, q3 FLOAT;
  DECLARE rads FLOAT DEFAULT 0;
  SET pi = PI();
  SET lat1 = lat1 * pi / 180;
  SET lon1 = lon1 * pi / 180;
  SET lat2 = lat2 * pi / 180;
  SET lon2 = lon2 * pi / 180;
  SET q1 = COS(lon1-lon2);
  SET q2 = COS(lat1-lat2);
  SET q3 = COS(lat1+lat2);
  SET rads = ACOS( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) ); 
  RETURN 6378.388 * rads;
END;
|
DELIMITER ;

-- toronto to montreal (505km):
select geodistkm(43.6667,-79.4167,45.5000,-73.5833);
+----------------------------------------------+
| geodistkm(43.6667,-79.4167,45.5000,-73.5833) |
+----------------------------------------------+
|                           505.38836669921875 |
+----------------------------------------------+</pre> <a href="http://www.posteet.com/tags/distance">[distance]</a>  <a href="http://www.posteet.com/tags/function">[function]</a>  <a href="http://www.posteet.com/tags/lat">[lat]</a>  <a href="http://www.posteet.com/tags/latitude">[latitude]</a>  <a href="http://www.posteet.com/tags/lng">[lng]</a>  <a href="http://www.posteet.com/tags/longitude">[longitude]</a>  <a href="http://www.posteet.com/tags/maps">[maps]</a>  <a href="http://www.posteet.com/tags/mysql">[mysql]</a> ]]>        </description>
        <dc:creator>spirit</dc:creator>
        <pubDate>Mon, 09 Feb 2009 20:07:38 +0100</pubDate>

            <category>distance</category>
            <category>function</category>
            <category>lat</category>
            <category>latitude</category>
            <category>lng</category>
            <category>longitude</category>
            <category>maps</category>
            <category>mysql</category>
    
    <feedburner:origLink>http://www.posteet.com/view/1555</feedburner:origLink></item>


</channel>
</rss>

