<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux &#38;&#38; PHP @ NomikOS – BLOG &#187; MySQL-DB</title>
	<atom:link href="http://nomikos.info/category/mysql-db/feed" rel="self" type="application/rss+xml" />
	<link>http://nomikos.info</link>
	<description>Artículos y temas sobre programación web: Linux, PHP, jQuery, CodeIgniter/Kohana y mis trabajos en linea en RAC. Igor Parra Bastias – NomikOS</description>
	<lastBuildDate>Wed, 18 Aug 2010 14:22:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>phpMyAdmin &#8211; Autentificación en localhost y en sevidores en línea.</title>
		<link>http://nomikos.info/2010/07/20/phpmyadmin-autentificacion-en-localhost-y-en-sevidores-en-linea.html</link>
		<comments>http://nomikos.info/2010/07/20/phpmyadmin-autentificacion-en-localhost-y-en-sevidores-en-linea.html#comments</comments>
		<pubDate>Wed, 21 Jul 2010 03:09:57 +0000</pubDate>
		<dc:creator>NomikOS</dc:creator>
				<category><![CDATA[Herramientas para programación web]]></category>
		<category><![CDATA[MySQL-DB]]></category>

		<guid isPermaLink="false">http://nomikos.info/?p=1690</guid>
		<description><![CDATA[Hay 4 tipos de autentificación en PMA de las cuales 2 son las más importantes: config y cookie: 123# en config.inc.php: valores posibles: # config, cookie, http, sigon $cfg&#91;'Servers'&#93;&#91;$i&#93;&#91;'auth_type'&#93; = ''; config Es el más básico y sencillo. Ingresas los datos del usuario que puede acceder a la base de datos y su password, y [...]


Posts relacionados:<ol><li><a href='http://nomikos.info/2010/06/09/phpmyadmin-mostrar-todos-los-registros-y-otras-configuraciones-ocultas.html' rel='bookmark' title='Permanent Link: phpMyAdmin &#8211; Mostrar todos los registros y otras configuraciones ocultas.'>phpMyAdmin &#8211; Mostrar todos los registros y otras configuraciones ocultas.</a></li>
<li><a href='http://nomikos.info/2009/05/29/uso-de-la-linea-de-comando-para-mysql.html' rel='bookmark' title='Permanent Link: Uso de la linea de comando para MySQL.'>Uso de la linea de comando para MySQL.</a></li>
<li><a href='http://nomikos.info/2010/06/05/midnight-commander-%e2%80%93-login-automatico-en-ftp.html' rel='bookmark' title='Permanent Link: midnight-commander – login automático en FTP usando .netrc'>midnight-commander – login automático en FTP usando .netrc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hay 4 tipos de autentificación en PMA de las cuales 2 son las más importantes: <em>config</em> y <em>cookie</em>:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># en config.inc.php: valores posibles:<br />
</span><span style="color: #666666; font-style: italic;"># config, cookie, http, sigon<br />
</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'auth_type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h1>config</h1>
<p>Es el más básico y sencillo. Ingresas los datos del usuario que puede acceder a la base de datos y su password, y te olvidas.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># en config.inc.php<br />
</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'auth_type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'config'</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'usuario'</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'password_de_usuario'</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>En esta forma puedes acceder a PMA, y por consiguiente a las bases de datos configuradas en él, directamente, sin tener que dar datos de usuario y password cada vez. Este usuario debiera tener suficientes privilegios como para poder crear bases de datos y manipular sus tablas: crear, borrar, etc.</p>
<p>Si te complicas demasiado ponle el usuario <em>root</em> y su password (me refiero al root de mysql, no de tu sistema operativo). Obviamente este consejo es para un ambiente de desarrollo en localhost y en que no manejas cuentas bancarias. Si metes la pata argüiré demencia temporal.</p>
<blockquote><p>Fíjate que PMA puede usarse con varios servidores y que los enumera usando el array $cfg['Servers'].</p></blockquote>
<p>Este método puede usarse sin problemas en localhost, aunque se recomienda que tu computador este tras una firewall. Lo cual es una práctica recomendable en general.</p>
<h1>cookie</h1>
<p>Este es el método más usado, especialmente en servidores en línea porque permite ingresar a varios usuarios remotos y provee seguridad a través de un desafío de autentificación vía password. Debes ingresar los siguientes datos:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># en config.inc.php<br />
</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'auth_type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'cookie'</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// deja vacío</span><br />
<span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// deja vacío</span><br />
<br />
<span style="color: #666666; font-style: italic;"># ingresa una frase secreta para poder encriptar passwords<br />
</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'blowfish_secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'parle ocaso detum cko ares tobo'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># duración de la cookie<br />
</span><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'LoginCookieValidity'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1800</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<li>blowfish_secret: Cualquier frase, con o sin sentido sirve, no es necesario recordarla, solo se usa internamente.</li>
<p>Ahora se te pedirá identificarte cada vez que quieras usar PMA:</p>
<p><a href="http://nomikos.info/wp-content/uploads/2010/07/phpmyadmin-login.png"><img src="http://nomikos.info/wp-content/uploads/2010/07/phpmyadmin-login.png" alt="" title="phpmyadmin-login" width="404" height="364" class="aligncenter size-full wp-image-1697" /></a></p>
<h1>LoginCookieValidity</h1>
<p>Este dato es importante. Generalmente cuando se esta desarrollando localmente sólo se usa PMA de vez en cuando, por lo que pasados 1800 segundos (media hora) sin usar te vuelve a pedir autentificación.<br />
Una putada si me permites la expresión. Bueno, este valor puedes ampliarlo cuanto quieras. Pero ten en cuenta que no puede superar al valor <em>session.gc_maxlifetime</em> definido en <em>php.ini</em> o no logrará el efecto esperado.</p>
<p>Luego, debes editar estos dos valores al unisono.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># en config.inc.php</span><br />
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'LoginCookieValidity'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #000000;">36000</span>; <span style="color: #000000; font-weight: bold;">//</span> <span style="color: #000000;">10</span> horas<br />
<br />
<span style="color: #666666; font-style: italic;"># en php.ini</span><br />
; After this number of seconds, stored data will be seen <span style="color: #c20cb9; font-weight: bold;">as</span> <span style="color: #ff0000;">'garbage'</span> and<br />
; cleaned up by the garbage collection process.<br />
session.gc_maxlifetime = <span style="color: #000000;">36000</span> <span style="color: #000000; font-weight: bold;">//</span> <span style="color: #000000;">10</span> horas</div></td></tr></tbody></table></div>
<p>PMA muy servicialmente te advierte de esto:</p>
<blockquote><p>Your PHP parameter session.gc_maxlifetime is lower that cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.</p></blockquote>
<p>Esta de moda no hacerme ningún comentario así que sin más que añadir, chaolin no +.</p>


<p>Posts relacionados:<ol><li><a href='http://nomikos.info/2010/06/09/phpmyadmin-mostrar-todos-los-registros-y-otras-configuraciones-ocultas.html' rel='bookmark' title='Permanent Link: phpMyAdmin &#8211; Mostrar todos los registros y otras configuraciones ocultas.'>phpMyAdmin &#8211; Mostrar todos los registros y otras configuraciones ocultas.</a></li>
<li><a href='http://nomikos.info/2009/05/29/uso-de-la-linea-de-comando-para-mysql.html' rel='bookmark' title='Permanent Link: Uso de la linea de comando para MySQL.'>Uso de la linea de comando para MySQL.</a></li>
<li><a href='http://nomikos.info/2010/06/05/midnight-commander-%e2%80%93-login-automatico-en-ftp.html' rel='bookmark' title='Permanent Link: midnight-commander – login automático en FTP usando .netrc'>midnight-commander – login automático en FTP usando .netrc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://nomikos.info/2010/07/20/phpmyadmin-autentificacion-en-localhost-y-en-sevidores-en-linea.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Uso de la linea de comando para MySQL.</title>
		<link>http://nomikos.info/2009/05/29/uso-de-la-linea-de-comando-para-mysql.html</link>
		<comments>http://nomikos.info/2009/05/29/uso-de-la-linea-de-comando-para-mysql.html#comments</comments>
		<pubDate>Fri, 29 May 2009 14:51:11 +0000</pubDate>
		<dc:creator>NomikOS</dc:creator>
				<category><![CDATA[MySQL-DB]]></category>

		<guid isPermaLink="false">http://nomikos.info/?p=1248</guid>
		<description><![CDATA[photo credit: dmuth Esto es un tutorial introductorio (bastante bueno me permito decir). Si quieres una excelente lista de consulta rápida de comandos http://www.pantz.org/software/mysql/mysqlcommands.html MySQL dispone de una interface/shell llamada mysql. Con ella podrás interactuar en forma rápida con tus bases de datos, especialmente si accades a un servidor remoto, como es el caso de [...]


Posts relacionados:<ol><li><a href='http://nomikos.info/2010/07/20/phpmyadmin-autentificacion-en-localhost-y-en-sevidores-en-linea.html' rel='bookmark' title='Permanent Link: phpMyAdmin &#8211; Autentificación en localhost y en sevidores en línea.'>phpMyAdmin &#8211; Autentificación en localhost y en sevidores en línea.</a></li>
<li><a href='http://nomikos.info/2009/04/28/uso-de-su-y-sudo-para-simular-al-usuario-root.html' rel='bookmark' title='Permanent Link: Uso de su y sudo para simular al usuario root.'>Uso de su y sudo para simular al usuario root.</a></li>
<li><a href='http://nomikos.info/2009/08/01/chmod-modificacion-de-accesos-a-un-archivo.html' rel='bookmark' title='Permanent Link: Comando chmod &#8211; Modificación de accesos a un archivo.'>Comando chmod &#8211; Modificación de accesos a un archivo.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="photodropper"><a href="http://www.flickr.com/photos/30647744@N00/4344183950/" title="MySQL database monitor" target="_blank"><img src="http://farm5.static.flickr.com/4038/4344183950_d10cd02302_m.jpg" alt="MySQL database monitor" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-sa/2.0/" title="Attribution-ShareAlike License" target="_blank"><img src="http://nomikos.info/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/30647744@N00/4344183950/" title="dmuth" target="_blank">dmuth</a></small></div>
<p>Esto es un tutorial introductorio (bastante bueno me permito decir). Si quieres una excelente lista de consulta rápida de comandos <a target="_blank" href="http://www.pantz.org/software/mysql/mysqlcommands.html">http://www.pantz.org/software/mysql/mysqlcommands.html</a></p>
<p><br style="clear:both"></p>
<p>MySQL dispone de una interface/shell llamada mysql. Con ella podrás interactuar en forma rápida con tus bases de datos, especialmente si accades a un servidor remoto, como es el caso de servidores web.</p>
<p>Tiene capacidades readline lo que fundamentalmente te permite recorrer el historial de entradas/comandos usando las teclas de cursor (arriba y abajo) y autocompletación usando [TAB].</p>
<p>En adelante suponemos:</p>
<li> fanquito: nombre de usuario.</li>
<li> mibd: nombre de una base de datos.</li>
<li> mipassword: tu password de acceso a MySQL (Esta password no es necesariamente la misma de la de tu cuenta de usuario).</li>
<li> Las mayúsculas no son obligatorias aunque son muy usadas para mayor claridad como ya verás.</li>
<h1>Acceso a la linea de comando</h1>
<p>Simplemente escribe mysql.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ mysql <span style="color: #7a0874; font-weight: bold;">&#91;</span>ENTER<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
Welcome to the MySQL monitor. &nbsp;Commands end with ; or \g.<br />
Your MySQL connection <span style="color: #c20cb9; font-weight: bold;">id</span> is <span style="color: #000000;">22</span><br />
Server version: 5.0.75-log Source distribution<br />
<br />
Type <span style="color: #ff0000;">'help;'</span> or <span style="color: #ff0000;">'\h'</span> <span style="color: #000000; font-weight: bold;">for</span> help. Type <span style="color: #ff0000;">'\c'</span> to <span style="color: #c20cb9; font-weight: bold;">clear</span> the buffer.<br />
<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>Asi es, tu prompt es ahora mysql>. Y como muy amigablemente te recibe es con un: Tipée help si necesita ayuda.</p>
<h1>Super valiosa ayuda para usar la linea de comando</h1>
<p>Simplemente escribe help.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">help</span><br />
<br />
For information about MySQL products and services, visit:<br />
&nbsp; &nbsp;http:<span style="color: #000000; font-weight: bold;">//</span>www.mysql.com<span style="color: #000000; font-weight: bold;">/</span><br />
For developer information, including the MySQL Reference Manual, visit:<br />
&nbsp; &nbsp;http:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span><br />
To buy MySQL Network Support, training, or other products, visit:<br />
&nbsp; &nbsp;https:<span style="color: #000000; font-weight: bold;">//</span>shop.mysql.com<span style="color: #000000; font-weight: bold;">/</span><br />
<br />
List of all MySQL commands:<br />
Note that all text commands must be first on line and end with <span style="color: #ff0000;">';'</span><br />
? &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#40;</span>\?<span style="color: #7a0874; font-weight: bold;">&#41;</span> Synonym <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #ff0000;">'help'</span>.<br />
<span style="color: #c20cb9; font-weight: bold;">clear</span> &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#40;</span>\c<span style="color: #7a0874; font-weight: bold;">&#41;</span> Clear command.<br />
connect &nbsp; <span style="color: #7a0874; font-weight: bold;">&#40;</span>\r<span style="color: #7a0874; font-weight: bold;">&#41;</span> Reconnect to the server. Optional arguments are db<span style="color: #000000; font-weight: bold;">/</span>host.<br />
... <span style="color: #7a0874; font-weight: bold;">&#40;</span>varios comandos<span style="color: #7a0874; font-weight: bold;">&#41;</span> ...<br />
<br />
For server side <span style="color: #7a0874; font-weight: bold;">help</span>, <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'help contents'</span><br />
<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>De aquí aprendemos 2 cosas muy importantes:</p>
<li> Para ejecutar un comando debes terminar su enunciado con un punto y coma (;) y [ENTER]. Puedes escribir en varias lineas. El shell te responderá en cada nueva linea con el símbolo (->) que significa que aún espera el punto y coma.</li>
<li> Y lejos, lo mejor: Te dice que si de verdad quieres ayuda tipées help contents.</li>
<p>Simplemente escribe help contents.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># ayuda en general</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">help</span> contents<br />
You asked <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">help</span> about <span style="color: #7a0874; font-weight: bold;">help</span> category: <span style="color: #ff0000;">&quot;Contents&quot;</span><br />
For <span style="color: #c20cb9; font-weight: bold;">more</span> information, <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'help &lt;item&gt;'</span>, where <span style="color: #000000; font-weight: bold;">&lt;</span>item<span style="color: #000000; font-weight: bold;">&gt;</span> is one of the<br />
following categories:<br />
&nbsp; &nbsp;Account Management<br />
&nbsp; &nbsp;Administration<br />
&nbsp; &nbsp;Data Definition<br />
&nbsp; &nbsp;Data Manipulation<br />
&nbsp; &nbsp;Data Types<br />
&nbsp; &nbsp;Functions<br />
&nbsp; &nbsp;Functions and Modifiers <span style="color: #000000; font-weight: bold;">for</span> Use with GROUP BY<br />
&nbsp; &nbsp;Geographic Features<br />
&nbsp; &nbsp;Language Structure<br />
&nbsp; &nbsp;Storage Engines<br />
&nbsp; &nbsp;Stored Routines<br />
&nbsp; &nbsp;Table Maintenance<br />
&nbsp; &nbsp;Transactions<br />
&nbsp; &nbsp;Triggers<br />
<br />
<span style="color: #666666; font-style: italic;"># ayuda sobre comandos de adminstración</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">help</span> administration<br />
You asked <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">help</span> about <span style="color: #7a0874; font-weight: bold;">help</span> category: <span style="color: #ff0000;">&quot;Administration&quot;</span><br />
For <span style="color: #c20cb9; font-weight: bold;">more</span> information, <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'help &lt;item&gt;'</span>, where <span style="color: #000000; font-weight: bold;">&lt;</span>item<span style="color: #000000; font-weight: bold;">&gt;</span> is one of the<br />
following topics:<br />
&nbsp; &nbsp;DESCRIBE<br />
&nbsp; &nbsp;FLUSH QUERY CACHE<br />
&nbsp; &nbsp;HELP COMMAND<br />
&nbsp; &nbsp;HELP STATEMENT<br />
<br />
<span style="color: #666666; font-style: italic;"># ayuda sobre comando DESCRIBE</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">help</span> describe<br />
Name: <span style="color: #ff0000;">'DESCRIBE'</span><br />
Description:<br />
Syntax:<br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span>DESCRIBE <span style="color: #000000; font-weight: bold;">|</span> DESC<span style="color: #7a0874; font-weight: bold;">&#125;</span> tbl_name <span style="color: #7a0874; font-weight: bold;">&#91;</span>col_name <span style="color: #000000; font-weight: bold;">|</span> wild<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<br />
DESCRIBE provides information about the columns <span style="color: #000000; font-weight: bold;">in</span> a table. It is a<br />
shortcut <span style="color: #000000; font-weight: bold;">for</span> SHOW COLUMNS FROM. As of MySQL 5.0.1, these statements<br />
also display information <span style="color: #000000; font-weight: bold;">for</span> views. <span style="color: #7a0874; font-weight: bold;">&#40;</span>See <span style="color: #7a0874; font-weight: bold;">&#91;</span>HELP SHOW COLUMNS<span style="color: #7a0874; font-weight: bold;">&#93;</span>.<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
URL: http:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>refman<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>en<span style="color: #000000; font-weight: bold;">/</span>describe.html<br />
<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<h1>Creación de una cuenta de usuario para MySQL</h1>
<p>MySQL tiene un subconjunto propio de usuarios y estos deben ser creados explícitamente.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># sólo en MySQL 5.0.2+</span><br />
<span style="color: #666666; font-style: italic;"># para versiones anteriores usa GRANT</span><br />
CREATE USER fanquito IDENTIFIED BY <span style="color: #ff0000;">'mipassword'</span>;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.01</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Esto crea una cuenta identificada como fanquito (aqui cuenta y usuario son sinónimos) en localhost, que es el host donde te encuentras ahora mismo, y es lo que la mayor parte de las veces necesitarás. Este nuevo usuario no tiene ningún privilegio, estos se asignan con GRANT. Luego este comando “CREATE USER” puedes servirte para crear una lista de usuarios de los cuales aún no sabes que tareas van a realizar. La forma más realista de crear nuevos usuarios es con GRANT.</p>
<h1>Creación de una cuenta de usuario para MySQL con el comando GRANT</h1>
<p>GRANT permite crear usuarios y asignarle privilegios al mismo tiempo.</p>
<p>A todo esto los privilegios determinan que operaciones puedes realizar en que bases de datos (y sus tablas). Por ejemplo:</p>
<li> SELECT: leer.</li>
<li> INSERT: escribir.</li>
<li> DELETE: borrar.</li>
<li> UPDATE: actualizar.</li>
<p>Veamos:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># crear el usuario &quot;fanquito2&quot; con password &quot;mipassword&quot;</span><br />
<span style="color: #666666; font-style: italic;"># que pueda leer y reescribir registros en todas las tablas de midb</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> GRANT SELECT, UPDATE, DELETE ON midb.<span style="color: #000000; font-weight: bold;">*</span> TO fanquito2 IDENTIFIED<br />
-<span style="color: #000000; font-weight: bold;">&gt;</span> by <span style="color: #ff0000;">'mipassword'</span>;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.01</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Si el usuario ya existe sólo asigna/reasigna los nuevos privilegios y en este caso no es necesario agregar “IDENTIFIED by ‘mipassword’”.<br />
Mirando más de cerca el enunciado. “ON midb.*” determina donde será efectivos los privilegios.</p>
<p>Usa:</p>
<li> *.* para todas las bases de datos.</li>
<li> midb.mitabla para especificar sólo cierta tabla.</li>
<p>Si un usuario ha metido la pata, como por ejemplo, borrando todos los registros de una tabla de acceso colectivo (shú) le puedes dar una buena patada así:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># revocar todos los privilegios en toda la base de datos</span><br />
<span style="color: #666666; font-style: italic;"># para el usuario fanquito2</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> REVOKE <span style="color: #000000; font-weight: bold;">*</span> ON rac.<span style="color: #000000; font-weight: bold;">*</span> FROM fanquito2;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.01</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Si sólo quieres quitarle la posibilidad de seguir cambiando el estado de la base de datos:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># averiguar que privilegios tiene el manos de hacha</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> SHOW GRANTS FOR fanquito2;<br />
+----------------------------------------------------------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Grants <span style="color: #000000; font-weight: bold;">for</span> fanquito2<span style="color: #000000; font-weight: bold;">@%</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+----------------------------------------------------------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> GRANT USAGE ON <span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #000000; font-weight: bold;">*</span> TO <span style="color: #ff0000;">'fanquito2'</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #ff0000;">'%'</span> IDENTIFIED BY PASSWORD <span style="color: #ff0000;">'*CEE8'</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> GRANT SELECT, UPDATE, DELETE ON <span style="color: #000000; font-weight: bold;">`</span>midb<span style="color: #000000; font-weight: bold;">`</span>.<span style="color: #000000; font-weight: bold;">*</span> TO <span style="color: #ff0000;">'fanquito2'</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #ff0000;">'%'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+----------------------------------------------------------------------+<br />
<span style="color: #000000;">3</span> rows <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># revocar privilegios de escritura</span><br />
<span style="color: #666666; font-style: italic;"># para el usuario fanquito2</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> REVOKE UPDATE, DELETE ON rac.<span style="color: #000000; font-weight: bold;">*</span> FROM fanquito2;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Muy bien. Con eso debiera dejar de dar problemas el susodicho. Ahora si que si se trataba de la tabla con los datos de lo me debes:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># borrar cuenta/usuario fanquito2</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> DROP USER fanquito2;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.01</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<h1>Datos comunes en scripts PHP referentes a bases de datos</h1>
<p>El script necesita saber tus datos de usuario en la base de datos para poder acceder en tu nombre. Generalmente se definen en una manera parecida a esta:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_TYPE'</span>, <span style="color: #ff0000;">'mysql'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_NAME'</span>, <span style="color: #ff0000;">'midb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
<span style="color: #666666; font-style: italic;"># en el mismo servidor</span><br />
define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_HOST'</span>, <span style="color: #ff0000;">'localhost'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
<span style="color: #666666; font-style: italic;"># en la base de datos sudb un servidor remoto</span><br />
define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_HOST'</span>, <span style="color: #ff0000;">'sudb.servidorremoto.com'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_USER'</span>, <span style="color: #ff0000;">'fanquito'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
define<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'DB_PASS'</span>, <span style="color: #ff0000;">'mipassword'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>La palabra reservada “define” es propia de PHP y asigna contantes. Estas a diferencia de las variables son superglobales o sea pueden ser accedidas desde cualquier función/clase (y no pueden ser redefinidas posteriormente).</p>
<h1>Importación y exportación de tablas y bases de datos</h1>
<p>Para empezar (que ingenuo fuí), una ventaja insuperable y que yo comúnmente aprovecho, por sobre una interface web como phpmyadmin, es la velocidad con que puedes importar y exportar tablas y bases de datos enteras.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># importar archivo sql</span><br />
<span style="color: #666666; font-style: italic;"># no importa la extension sql. sólo debe ser un archivo de texto</span><br />
<span style="color: #666666; font-style: italic;"># con instrucciones entendibles por MySQL</span><br />
mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-pmipassword</span> mibd <span style="color: #000000; font-weight: bold;">&lt;</span> tubd.sql<br />
<br />
<span style="color: #666666; font-style: italic;"># exportar base de datos entera a archivo sql</span><br />
<span style="color: #666666; font-style: italic;"># sabiamente agregamos .sql pero no es necesario</span><br />
mysqldump <span style="color: #660033;">-u</span> root <span style="color: #660033;">-pmipassword</span> mibd <span style="color: #000000; font-weight: bold;">&gt;</span> midb.sql<br />
<br />
<span style="color: #666666; font-style: italic;"># exportar sólo una tabla</span><br />
mysqldump <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> mibd mitabla<span style="color: #000000; font-weight: bold;">&gt;</span> mitabla.sql</div></td></tr></tbody></table></div>
<p>Fíjate que en el ultimo comando no escribimos la password, sólo “-p”. Esto es muy bueno si quieres mantener oculta tu password, tanto de ojos sobre tu hombro (como cuando aparecen sólo asteriscos en una página web) como de los logs del servidor.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># usando la opción -p podrás ingresar tu password en una manera segura</span><br />
$ mysqldump <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> mibd mitabla<span style="color: #000000; font-weight: bold;">&gt;</span> mitabla.sql<br />
Enter password:</div></td></tr></tbody></table></div>
<p>Personalmente creo que en un ambiente distendido de trabajo como por ejemplo, el manejo normal de tu blog, es lícito escribir tu password en la linea de comando para posteriormente usar history y ejecutar comandos rápidamente. Depende de tí.</p>
<h1>Comandos muy usados para consultar tus tablas</h1>
<p>Vuelvo a decir que esta es la manera ideal de trabajar si quieres terminar antes de las 5 de la tarde para alcanzar a tomarte una cerveza antes de que llegue la noche.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># mostrar todas las bases de datos</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> show databases;<br />
+--------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Database &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+--------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> information_schema <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> mysql &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> mibd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+--------------------+<br />
<span style="color: #000000;">4</span> rows <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># trabajar con una en particular</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> use mibd;<br />
Reading table information <span style="color: #000000; font-weight: bold;">for</span> completion of table and column names<br />
You can turn off this feature to get a quicker startup with <span style="color: #660033;">-A</span><br />
<br />
Database changed<br />
<br />
<span style="color: #666666; font-style: italic;"># mostrar sus tablas</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> show tables;<br />
+---------------------------------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Tables_in_rac &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+---------------------------------------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> data_control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_record1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_record2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_source &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_status_autotrader_control &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_status_ebay_control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_status_exchangeandmart_control <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data_status_fish4_control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+---------------------------------------------+<br />
<span style="color: #000000;">8</span> rows <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># mostrar estructura de una tabla en particular</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> describe data_control;<br />
+--------------+-------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+--------------+-------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> auto_increment <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> shedule_on &nbsp; <span style="color: #000000; font-weight: bold;">|</span> tinyint<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> admin &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">20</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> password &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">32</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> data &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> tinyint<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+--------------+-------------+------+-----+---------+----------------+<br />
<span style="color: #000000;">5</span> rows <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.02</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># en una tabla de autos (170000 aprox.) con varias</span><br />
<span style="color: #666666; font-style: italic;"># características (columnas)</span><br />
<span style="color: #666666; font-style: italic;"># quiero saber cuantos hay de cada uno (columna marca)</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">select</span> distinct<span style="color: #7a0874; font-weight: bold;">&#40;</span>marca<span style="color: #7a0874; font-weight: bold;">&#41;</span>,count<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">as</span> c from data_record1 group by<br />
-<span style="color: #000000; font-weight: bold;">&gt;</span> marca order by c desc;<br />
+---------------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> marca &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> c &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+---------------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> VAUXHALL &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">32514</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> RENAULT &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">30945</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> PEUGEOT &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">29008</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> MERCEDES-BENZ <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">22985</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> CITROEN &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">21015</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> TOYOTA &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">17921</span> <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> FIAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">16676</span> <span style="color: #000000; font-weight: bold;">|</span><br />
... etc ...<br />
+---------------+-------+<br />
<span style="color: #000000;">100</span> rows <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4.39</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># borrar todos los que no indican año</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> delete from data_record1 where <span style="color: #007800;">year</span>=<span style="color: #ff0000;">''</span>;<br />
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.11</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<h1>Definir password de root</h1>
<p>Aclaremos que este root se refiere al usuario root del conjunto de usuarios de MySQL y no del sistema operativo. Son distintos. Cuando se instala MySQL viene el usuario root predefinido y sin password.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># definir una password para root</span><br />
<span style="color: #666666; font-style: italic;"># primero seleccionamos la bases de datos &quot;mysql&quot;</span><br />
<span style="color: #666666; font-style: italic;"># esta es parte de MySQL y siempre existe</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> USE mysql;<br />
<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> UPDATE user SET <span style="color: #007800;">password</span>=PASSWORD<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;mipassword&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> WHERE <span style="color: #007800;">user</span>=<span style="color: #ff0000;">&quot;root&quot;</span>;<br />
<br />
<span style="color: #666666; font-style: italic;"># recargar cache interno de MySQL</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> FLUSH PRIVILEGES;</div></td></tr></tbody></table></div>
<h1>Recuperar password de root</h1>
<p>Sin comentarios.<br />
Para esto debes ser root en el sistema operativo de tal manera que puedas reiniciar el demonio mysqld.</p>
<p>Te daré los pasos calcados. Haz lo mismo que yo nena.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> cabeza de pollo de nuevo olvidaste tu password <span style="color: #000000; font-weight: bold;">&gt;</span>:<span style="color: #7a0874; font-weight: bold;">&#40;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># asumir privilegios de root</span><br />
<span style="color: #c20cb9; font-weight: bold;">su</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>ENTER<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
password:<br />
<br />
<span style="color: #666666; font-style: italic;"># parar mysld</span><br />
$ service stop mysqld<br />
Stopping the mysqld service<br />
<br />
<span style="color: #666666; font-style: italic;"># iniciar mysqld sin cargar tabla de privilegios</span><br />
$ mysqld_safe <span style="color: #660033;">--skip-grant-tables</span> <span style="color: #000000; font-weight: bold;">&amp;</span><br />
Starting mysqld daemon with databases from <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql<br />
<br />
$ mysql <span style="color: #660033;">-uroot</span><br />
ERROR <span style="color: #000000;">2002</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>HY000<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Can<span style="color: #ff0000;">'t connect to local MySQL server through<br />
socket '</span><span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>mysql.sock<span style="color: #ff0000;">' (2)<br />
<br />
# si, no es na'</span> <span style="color: #c20cb9; font-weight: bold;">as</span>í<br />
<span style="color: #666666; font-style: italic;"># dijo clarito: Starting mysqld daemon with databases from /var/lib/mysql</span><br />
<br />
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span><br />
$ mysql <span style="color: #660033;">-uroot</span><br />
Welcome to the MySQL monitor. &nbsp;Commands end with ; or \g.<br />
Your MySQL connection <span style="color: #c20cb9; font-weight: bold;">id</span> is <span style="color: #000000;">1</span><br />
Server version: 5.0.75-log Source distribution<br />
<br />
Type <span style="color: #ff0000;">'help;'</span> or <span style="color: #ff0000;">'\h'</span> <span style="color: #000000; font-weight: bold;">for</span> help. Type <span style="color: #ff0000;">'\c'</span> to <span style="color: #c20cb9; font-weight: bold;">clear</span> the buffer.<br />
<br />
<span style="color: #666666; font-style: italic;"># reasignar password para root</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> UPDATE user SET <span style="color: #007800;">password</span>=PASSWORD<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;mipassword&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> WHERE <span style="color: #007800;">user</span>=<span style="color: #ff0000;">&quot;root&quot;</span>;<br />
Query OK, <span style="color: #000000;">3</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.01</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Rows matched: <span style="color: #000000;">3</span> &nbsp;Changed: <span style="color: #000000;">3</span> &nbsp;Warnings: <span style="color: #000000;">0</span><br />
<br />
<span style="color: #666666; font-style: italic;"># abandonar la linea de comando</span><br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">exit</span><br />
<br />
<span style="color: #666666; font-style: italic;"># reiniciar mysqld</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">17</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">40</span> root<span style="color: #000000; font-weight: bold;">@</span>zenwalk<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ service restart mysqld<br />
Restarting the mysqld service</div></td></tr></tbody></table></div>
<p>Muy bien, me he alargado bastante en esto que sólo iba a ser una entrentención mañanera antes de trabajar de veras. Así que ponte con unos comentarios tú también, vale, colega?</p>


<p>Posts relacionados:<ol><li><a href='http://nomikos.info/2010/07/20/phpmyadmin-autentificacion-en-localhost-y-en-sevidores-en-linea.html' rel='bookmark' title='Permanent Link: phpMyAdmin &#8211; Autentificación en localhost y en sevidores en línea.'>phpMyAdmin &#8211; Autentificación en localhost y en sevidores en línea.</a></li>
<li><a href='http://nomikos.info/2009/04/28/uso-de-su-y-sudo-para-simular-al-usuario-root.html' rel='bookmark' title='Permanent Link: Uso de su y sudo para simular al usuario root.'>Uso de su y sudo para simular al usuario root.</a></li>
<li><a href='http://nomikos.info/2009/08/01/chmod-modificacion-de-accesos-a-un-archivo.html' rel='bookmark' title='Permanent Link: Comando chmod &#8211; Modificación de accesos a un archivo.'>Comando chmod &#8211; Modificación de accesos a un archivo.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://nomikos.info/2009/05/29/uso-de-la-linea-de-comando-para-mysql.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
