Home › Forum › Problemi Vari con WP › Problema con il restore del db
-
AutorePost
-
-
30 Dicembre 2010 alle 20:39 #16201guidolandaPartecipante
Ho avuto necessità di ripristinare il db perchè sono cambiati dei percorsi assoluti di img
Ho provveduto prima a fare il bck fleggando il ceck su drop table, ho apportato le modifiche e poi ho provveduto a fare il restore via phpMyAdmin, ma lo stesso durante l’esecuzione mi ha restituito questo errore:
— phpMyAdmin SQL Dump
— version 2.8.0.2
—
— Host: sql.blogolanda.it
— Generato il: 30 Dic, 2010 at 12:05 PM
— Versione MySQL: 5.0.32
— Versione PHP: 4.3.10-22
—
— Database: nome database
—
—
—
— Struttura della tabella wp_commentmeta
—
DROP TABLE IF EXISTS wp_commentmeta;
Messaggio di MySQL: Documentazione
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘à¯Â»Â¿
DROP TABLE IF EXISTS wp_commentmeta at line 1
Ovviamente il blog aveva il db originario.. non penso che avrei dovuto svuotarlo prima di fare il restore (ceck su drop table in fase di bck non serve proprio a questo ?)
Il blog sembra non aver importanto alcun riferimento del db modificato (i percorsi assoluti delle img sono rimasti invariati come in origine)
1) Perchè mi da questo errore il phpMyAdmin?
2) A fronte di questo errore effettivamente nessuna parte del db modificato è stato installato ?
3) Come posso effettuare correttamente il restore del db modificato ?
Grazie in anticipo.. spero possiate aiutarmi
-
3 Gennaio 2011 alle 2:20 #79986torejxPartecipante
Come hai fatto il restore? Usando l’opzione “Importa” di phpmyadmin? Prova ad eseguire il codice che hai nel file di backup (che hai esportato, mi pare di aver capito) come query e non ad importarlo.
Ma prima, vai sulla riga #1064 e vedi di cosa si tratta, al limite posta qui la riga intera che ci diamo un’occhiata.
-
3 Gennaio 2011 alle 18:08 #79998guidolandaPartecipante
Grazie torejx per il prezioso riscontro
>> Come hai fatto il restore? Usando l’opzione “Importa” di phpmyadmin?
Esatto
>> Prova ad eseguire il codice che hai nel file di backup (che hai esportato, mi pare di aver capito) come query
E come posso farlo ?
>> Ma prima, vai sulla riga #1064 e vedi di cosa si tratta, al limite posta qui la riga intera che ci diamo un’occhiata.
ehh, non sapevo si potesse leggere la riga #1064 credevo il msg di errore si fermasse li. Purtroppo non ho più il test di prova che ho effettuato quando ho postato la mia richiesta di assistenza.. e se provo adesso, importerei un db sul blog che non è più aggiornato.. ma posso provarlo a fare su un db e spazio di prova.. C’è una funzione di MyPhpAdmin che mi consente di vedere la riga #1064 ? Come posso fare ?
Sembra comunque essere un problema di encode tra i caratteri. Cosa che probabilmente è avvenuta quando ho modificato con il notepad del windows (con problemi di elaborazione.. il file scompattato del db è in realtà di 27 MB.. mi hanno consigliato per questo il Notepad++ .. ma vorrei provare a rintracciare le url con una query e sostituirle con quelle giuste dal MyPhpAdmin) alcune url del db
-
3 Gennaio 2011 alle 19:21 #80000torejxPartecipante
Quando hai fatto Importa, hai importato un file di testo, con estensione .sql, probabilmente. E’ in quel file che devi cercare la riga 1064.
Un’altra cosa che ho dimenticato e che mi hai fatto venire in mente tu, è che la collation (il set di caratteri) deve essere lo stesso sia per il db esportato che per quello di destinazione.
Per importare il db come query è sufficiente andare sulla tab SQL di phpmyadmin ed incollare l’intero contenuto del file .sql.
Per quanto riguarda la modifica, io uso il trova/sostituisci di notepad++ quando devo cambiare tutti gli URL (per il passaggio da locale a remoto); nel tuo caso, dovendo sostituire solo alcuni indirizzi, non è meglio farlo a mano da phpmyadmin (se i record sono pochi) o con uno script ad hoc?
-
3 Gennaio 2011 alle 19:34 #80001guidolandaPartecipante
>> nel tuo caso, dovendo sostituire solo alcuni indirizzi, non è meglio farlo a mano da phpmyadmin (se i record sono pochi) o con uno script ad hoc?
No sono 3.000 ;( e l’ultima volta ho impiegato 5 ore a farlo uno per volta visto che il notepad di Windows non riusciva a farlo in tempi brevi.. ora che devo operare su un nuovo db, perchè quello modificato è cambiato rispetto a quello di oggi per effetto di nuovi articoli e commenti del blog, devo trovare un sistema più veloce.
Mi domandavo se non fosse corretto esportare solo la tab wp_posts, modificarla e reimportarla di nuovo.
Vorrei provarlo a fare tramite delle query con il MyPhPAdmin
La query tipo dovrebbe essere
UPDATE tabella SET campo=REPLACE(campo,’VALORE_VECCHIO’,’VALORE_NUOVO’)
e quindi vestita per il caso dovrebbe essere:
UPDATE wp_posts SET post_content=REPLACE(post_content,’fotoalbum.ALICE.it’,’fotoalbum.VIRGILIO.it’)
Il problema è infatti questo:
http://images4.fotoalbum.ALICE.it/v…attativa-vi.jpg
non si vede + perchè è divenuto
http://images4.fotoalbum.VIRGILIO.i…attativa-vi.jpg
Ho provato comunque adesso a lanciare questa query per capire se posso individuare le occorrenze di “fotoalbum.alice.it”
SELECT post_content
FROM wp_posts
WHERE post_content LIKE %fotoalbum.alice.it%
LIMIT 0 , 30
ma MySql mi restituisce questo errore
Messaggio di MySQL: Documentazione
#1054 – Unknown column ‘%fotoalbum.alice.it%’ in ‘where clause’
Dove ho sbagliato ?
-
3 Gennaio 2011 alle 19:49 #80002torejxPartecipante
Se la modifica riguarda solo una tabella, allora puoi esportarla da sola e lavorarci.
Non ho mai usato la funzione replace di mysql, ma mi pare sia corretta la tua query, solo che non capisco perchè ti tronca la stringa. Magari potresti postarci un record di wp_post (o eventualmente solo il campo post_content).
Ho provato comunque adesso a lanciare questa query per capire se posso individuare le occorrenze di “fotoalbum.alice.it”
SELECT post_content
FROM wp_posts
WHERE post_content LIKE %fotoalbum.alice.it%
LIMIT 0 , 30
%fotoalbum.alice.it% va tra apici.
Tieni anche conto delle maiuscole, perchè se la tua collation è case sensitive alice.it è diverso da ALICE.it
-
3 Gennaio 2011 alle 20:07 #80005guidolandaPartecipante
>> Se la modifica riguarda solo una tabella, allora puoi esportarla da sola e lavorarci.
Si l’occorrenza della url all’img esterna si riferisce ai soli contenuti e quindi dovrebbe riguardare la sola tabella wp_posts
>> %fotoalbum.alice.it% va tra apici.
Ok.. non funzionava perchè l’avevo messo tra apici singole anzichè doppie (?)
>> Tieni anche conto delle maiuscole, perchè se la tua collation è case sensitive alice.it è diverso da ALICE.it
Si infatti.. era solo un sistema per evidenziare meglio la parte che cambia nella url.. difatti è tutto minuscolo
>> Non ho mai usato la funzione replace di mysql, ma mi pare sia corretta la tua query
A questo punto la query
UPDATE wp_posts SET post_content=REPLACE(post_content,’fotoalbum.ALICE.it’,’fotoalbum.VIRGILIO.it’)
dovrebbe avere doppi apici e quindi diventare
UPDATE wp_posts SET post_content=REPLACE(post_content,”fotoalbum.ALICE.it”,”fotoalbum.VIRGILIO.it”)
E’ corretto ?
Giusto per fare una prova solo su un record e vedere se funziona prima di fare qualche casino su tutti, come posso limitarlo a solo 1 ?
-
3 Gennaio 2011 alle 20:19 #80006torejxPartecipante
Le documentazioni usano esempi in cui racchiudono le stringhe tra apici singoli.. anch’io ho sempre usato apici singoli e non ho mai avuto problemi. Mi sembra strano che il problema sia quello, ma finché funziona……
Comunque, tanto per capire il problema, l’esempio che hai postato è giusto? Cioè la funzione replace tronca una parte del contenuto? (mi pare di capire che invece di VIRGILIO.it/v… scriva VIRGILIO.i…)
-
3 Gennaio 2011 alle 20:22 #80007guidolandaPartecipante
>> anch’io ho sempre usato apici singoli e non ho mai avuto problemi. Mi sembra strano che il problema sia quello, ma finché funziona…
Strano ma vero.. funziona solo con apici doppi. ma attenzione ho provveduto al momento solo a fare la query
SELECT post_content
FROM wp_posts
WHERE post_content LIKE %fotoalbum.alice.it%
e non a fare l’update
>> tanto per capire il problema, l’esempio che hai postato è giusto? Cioè la funzione replace tronca una parte del contenuto? (mi pare di capire che invece di VIRGILIO.it/v… scriva VIRGILIO.i…)
Non ho ancora provveduto ad operare con UPDATE.. lo farò solo uno db e uno spazio di prova per essere sicuro che non ci siano problemi poi con il db ufficiale (certo c’è sempre una copia di bck.. ma la precauzione non è mai troppa)
Se volessi utilizzare l’UPDATE solo 1 un record.. come posso fare ?
La Query
UPDATE wp_posts SET post_content=REPLACE(post_content,”fotoalbum.ALICE.it”,”fotoalbum.VIRGILIO.it”) LIMIT 1
è corretta ?
-
3 Gennaio 2011 alle 20:33 #80008torejxPartecipante
Se volessi utilizzare l’UPDATE solo 1 un record.. come posso fare ?
UPDATE wp_posts SET post_content=REPLACE(post_content,’fotoalbum.ALICE.it’,’fotoalbum.VIRGILIO.it’) where post_id=x
dove x è l’id di un post qualsiasi (assicurati che sia un post il cui campo post_content contenga fotoalbum.ALICE.it).
ps: ho usato post_id ma non sono sicuro che il campo si chiami cosà¬.. Non ho sottomano phpmyadmin per controllare, magari dacci un’occhiata tu.
edit: sà¬, mi pare sia corretta anche quella che hai scritto tu, ma dopo devi localizzare qual è il record modificato.. Magari aggiungi, prima di limit, una clausola ORDER BY nomeCampo in modo da poter reperire il record modificato più facilmente.
-
3 Gennaio 2011 alle 20:45 #80009guidolandaPartecipante
sà¬, mi pare sia corretta anche quella che hai scritto tu, ma dopo devi localizzare qual è il record modificato.
Ma il LIMIT credo sia tra quelli che già soddisfano questa condizione (al momento non sto modificado alcun record )
>> una clausola ORDER BY nomeCampo in modo da poter reperire il record modificato più facilmente
Uhmm.. cosa intendi dire esattamente ?
Comunque ripeto farà delle prove solo su u db di prova.. ti ringranzio per il prezioso aiuto
-
3 Gennaio 2011 alle 20:56 #80010torejxPartecipante
LIMIT 1 dice “fai l’update solo sulla prima riga dell’insieme restituito”.
WHERE post_id=x dice “fai l’update solo sul record con post_id uguale a x”.
In breve, se l’UPDATE ritorna un insieme di record cosଠordinato: A, B, C, con LIMIT 1 l’operazione sarà eseguita solo su A. Se l’insieme è B, A, C, ad essere aggiornato sarà invece B.
Se tu ci metti UPDATE …. ORDER BY post_title LIMIT 1, per trovare il record aggiornato ti basterà ordinare la tabella sul campo post_title e prendere il primo record
edit: non sono sicuro, ma mi pare di ricordare che in assenza di una clausola ORDER BY i record vengano ordinati in base alla chiave primaria.
-
4 Gennaio 2011 alle 9:46 #80014guidolandaPartecipante
FUNZIONAAAAAAAAA… FUNZIONAAAAAAAAAA.. GRAZIE .. GRAZIE .. GRAZIE..
Righe interessate: 827 (La query ha impiegato 40.5692 sec)
E io avevo impiegato 10 ore (5 ore a manina con il notepad di window e solo fino alla metà degli articoli)
Ho provato su uno spazio di test e per ulteriore precauzione prima di farlo sullo spazio ufficiale ho provveduto a far produrre la copia di bck (provando ad aprirlo dallo zip per verificarne l’integrità )
Ecco che questa Query ha funzionato
UPDATE wp_posts SET post_content=REPLACE(post_content,’fotoalbum.alice.it’,’fotoalbum.virgilio.it’)
senza doppi apici come invece richiede una query che contiene il like % (e non so il perchè)
Ho verificato inoltre, che il db veniva regolarmente importato. Sullo spazio di prova l’ho importato come file sql.zip facendo attenzione ad esportarlo in precedenza dal db originario con il “drop table”. Quindi in questo modo è possibile sovrapporre le tabelle senza alcun problema.
Pertanto molto probabilmente, il db scompatatto, editato con il notepad di windows, e salvato in fase di importazione aveva creato un problema di encode dei caratteri.
Ho fatto altre 2 prove
– tutte le modifiche apportate sul db con il MyPhpAdmin producono in tempo reale degli effetti di aggiornamento sul lato pubblico del blog
– e’ possibile svuotare le tabelle lasciando invariata la struttura
edit: non sono sicuro, ma mi pare di ricordare che in assenza di una clausola ORDER BY i record vengano ordinati in base alla chiave primaria.
Nella tab wp_posts ci sono diverse chiavi primarie, nel mio caso l’ordinamento ha avuto effetto in base alla chiave primaria “ID” un campo di tipo unsigned e auto increment. Quindi credo di si.. ossia che in assenza di una clausola ORDER BY i record vengano ordinati in base alla chiave primaria.
GRAzie per il tuo prezioso supporto.. mi è stato utile capire meglio i db..
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.