Posts in mysql

Cómo convertir una base de datos MySQL a UTF8

septiembre 21st, 2013 Posted by encodings, mysql, utf8 0 thoughts on “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.

ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;
2. Convertir cada tabla a UTF8.

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

junio 2nd, 2012 Posted by mamp, mysql, osx 0 thoughts on “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

mayo 15th, 2012 Posted by mysql 0 thoughts on “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

abril 2nd, 2012 Posted by mysql, php, wordpress 0 thoughts on “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

marzo 6th, 2012 Posted by mac, mysql 0 thoughts on “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

marzo 6th, 2012 Posted by mac, mysql 0 thoughts on “Running MySQL on Terminal in Leopard”

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

Running MAMP mysql on terminal

febrero 9th, 2012 Posted by mac, mysql 0 thoughts on “Running MAMP mysql on terminal”

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

How to stop MySQL on OSx

enero 2nd, 2012 Posted by mac, mysql 0 thoughts on “How to stop MySQL on OSx”
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo
/Library/StartupItems/MySQLCOM/MySQLCOM start
sudo
/Library/StartupItems/MySQLCOM/MySQLCOM restart

Cómo matar instancias previas de MySQL en Mac?

agosto 6th, 2011 Posted by mac, mysql 0 thoughts on “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.

mayo 24th, 2011 Posted by mysql, wordpress 0 thoughts on “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
Cambiar el 16 por el id de la categoria a buscar. 

Copyright © 2018 programadorfreelanceargentina.com

Programador Freelance Argentina