Strict Standards: Non-static method CodeColorerLoader::Enable() should not be called statically in /home/k6000169/public_html/wp-content/plugins/codecolorer/codecolorer.php on line 254
Mysql | Programador freelance argentina

mysql

Cómo convertir una base de datos MySQL a UTF8

Para convertir una base de datos cuyo encoding es latin1 (o cualquier otro) a UTF8 hay que:

1. Convertir la base de datos a UTF 8.

1
ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;

2. Convertir cada tabla a UTF8.

1
2
ALTER TABLE table_1_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE table_2_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

No funciona mysql en MAMP

120602 19:03:19  InnoDB: Waiting for the background threads to start
120602 19:03:20 InnoDB: 1.1.5 started; log sequence number 2155602691
120602 19:03:20 [ERROR] /Applications/MAMP/Library/bin/mysqld: unknown option ‘–skip-locking’
120602 19:03:20 [ERROR] Aborting
120602 19:03:20  InnoDB: Starting shutdown…
120602 19:03:21  InnoDB: Shutdown completed; log sequence number 2155602691
120602 19:03:21 [Note] /Applications/MAMP/Library/bin/mysqld: Shutdown complete
120602 19:03:21 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended

Luego de estar googleando una hora sin sentido encontré que en /etc tenía un my.cnf que estaba levantando MAMP y por lo cual daba problemas. Renombré dicho archivo a my-cnf y solved!

table data is not editable because there is no primary key defined for the table

Esto ocurre cuando se intenta realizar un SELECT sobre una tabla que no tiene PRIMARY KEY.

Para solucionar este problema hay que deshabilitar la opción “Safe Update”. Para realizar esto hay que ir a MySQLWorkbench > Preferences > SQL Editor. 

 

SQL to query categories with no childrens in WordPress

SELECT wp_terms.name, wp_terms.term_id
FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE wp_term_taxonomy.taxonomy = “category”
AND wp_terms.term_id NOT
IN (
SELECT DISTINCT parent
FROM `wp_term_taxonomy`
WHERE parent <>0
)
LIMIT 0 , 30

How to import a MySQL dump file

First create the database:

In the terminal:

mysql -u root -p

Inside MySQL command line:

mysql> create database foo;
mysql> exit;

In the terminal again:

mysql -u #username# -p #database# < #dump_file#

Import the

Running MySQL on Terminal in Leopard

/usr/local/mysql-5.1.59-osx10.6-x86/bin

Running MAMP mysql on terminal

/Applications/MAMP/Library/bin/mysql –host=localhost -uroot -proot

How to stop MySQL on OSx


1
<span>sudo </span><span>/</span><span>Library</span><span>/</span><span>StartupItems</span><span>/</span><span>MySQLCOM</span><span>/</span><span>MySQLCOM stop<br>sudo </span><span>/</span><span>Library</span><span>/</span><span>StartupItems</span><span>/</span><span>MySQLCOM</span><span>/</span><span>MySQLCOM start<br>sudo </span><span>/</span><span>Library</span><span>/</span><span>StartupItems</span><span>/</span><span>MySQLCOM</span><span>/</span><span>MySQLCOM restart</span>

Cómo matar instancias previas de MySQL en Mac?

Por consola

> sudo killall mysqld

Cómo listar las categorías de wordpress mediante un query de mysql.

SELECT DISTINCT ID, post_title, post_name, guid, post_date, post_content
FROM wp_posts AS p
INNER JOIN wp_term_relationships AS tr ON (
p.ID = tr.object_id

)
INNER JOIN wp_term_taxonomy AS tt ON (
tr.term_taxonomy_id = tt.term_taxonomy_id
AND taxonomy = 'category' AND tt.term_id
IN ( 16 )
)
ORDER BY id DESC

1
Cambiar el 16 por el id de la categoria a buscar.