WordPress SQL Befehle – Übersicht

WordPress ist eines der größten Blog Systeme der Welt. Wie so viele Web – Anwendungen läuft im Hintergrund eine SQL Datenbank. Zwar ist das Backend von WordPress wirklich super, aber um manche Änderungen vorzunehmen sind die WordPress SQL Befehle besser.

WordPress SQL Befehle
pixelcreatures / Pixabay

 

WordPress SQL Befehle – Übersicht

In der folgenden Übersicht haben wir einige SQL Befehle zusammengefasst, die ihr für die WordPress Datenbank gebrauchen könnt.

[thrive_text_block color=”light” headline=”URL der Seite”]

Seiten und Home URL anpassen:

UPDATE wp_options SET option_value = replace(option_value, ‚http://www.alteseite.com‘, ‚http://www.neueseite.com‘) WHERE option_name = ‚home‘ OR option_name = 'siteurl‘;

 

GUID Feld anpassen:

UPDATE wp_posts SET guid = REPLACE (guid, ‚http://www.alteseite.com‘, ‚http://www.neueseite.com‘);

 

URL im Content ändern:

UPDATE wp_posts SET post_content = REPLACE (post_content, ‚http://www.alteseite.com‘, ‚http://www.neueseite.com‘);

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Pfad der Bilder ändern”]

Globale Anpassung:

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src=“http://www.alteseite.com‘, 'src=“http://subdomain.neueseite.com‘);

 

GUID für die Bilder anpassen:

UPDATE wp_posts SET guid = REPLACE (guid, ‚http://www.alteseite.com‘, ‚http://subdomain.neueseite.com‘) WHERE post_type = ‚attachment‘;

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Adminsitration”]

Benutzername des „Admin“-Users ändern

UPDATE wp_users SET user_login = ‚Your New Username‘ WHERE user_login = ‚Admin‘;

 

Passwort zurück setzen

UPDATE wp_users SET user_pass = MD5( 'neues_passwort‘ ) WHERE user_login = ‚für-username‘;

[/thrive_text_block]
[thrive_text_block color=”light” headline=”Plugin´s”]

Alle Plugins deaktivieren

UPDATE wp_options SET option_value = ‚a:0:{}‘ WHERE option_name = ‚active_plugins‘;

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Tag´s”]

Nicht aktive Tags / nicht verknüpfte Tags anzeigen

SELECT * From wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag‘ AND wtt.count=0;

 

Alle nicht genutzten Tags löschen

DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );
DELETE FROM wp_term_taxonomy WHERE term_id not IN (SELECT term_id FROM wp_terms);
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Feed´s”]

Feed Cache löschen

DELETE FROM `wp_options` WHERE `option_name` LIKE (‚_transient%_feed_%‘);

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Seiten und Artikel”]

Artikel von einem Author zu einem anderen Author übertragen
Author ID auslesen

SELECT ID, display_name FROM wp_users;

Author übertragen

UPDATE wp_posts SET post_author = 'neue-author-id‘ WHERE post_author = ‚alte-author-id‘;

 

Beitrags Meta Daten anpassen

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, ‚http://www.oldwebsiteurl.com‘,'http://www.newwebsiteurl.com‘);

Text Suchen und Text Ersetzen

UPDATE wp_posts SET `post_content`
= REPLACE (`post_content`,
‚OriginalText‘,
‚NeuerText‘);

 

Alte Revisionen löschen

DELETE FROM wp_posts WHERE post_type = „revision“;

 

Alte Artikel anzeigen

SELECT * FROM `wp_posts`
WHERE `post_type` = ‚post‘
AND DATEDIFF(NOW(), `post_date`) > X

x = Days

 

Alte Artikel löschen

DELETE FROM `wp_posts`
WHERE `post_type` = ‚post‘
AND DATEDIFF(NOW(), `post_date`) > X

x = Days

 

Posts zu Seiten umwandeln

UPDATE wp_posts SET post_type = ‚page‘ WHERE post_type = ‚post‘

 

Seiten zu Posts umwandeln

UPDATE wp_posts SET post_type = ‚post‘ WHERE post_type = ‚page‘

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Kommentare”]

Alle Spam Kommentare löschen

DELETE FROM wp_comments WHERE comment_approved = 'spam‘;

spam“ kann ersetzt werden durch:
0 –> löscht alle Kommentare die Moderationen erwarten
1 –> bestätigte Kommentare

 

Kommentare deaktivieren ab einem bestimmten Datum

UPDATE wp_posts SET comment_status = ‚closed‘ WHERE post_date < ‚2010-01-01‘ AND post_status = ‚publish‘;

 

Kommentare mit einer bestimmten URL löschen

DELETE from wp_comments WHERE comment_author_url LIKE „%spamurl%“ ;

[/thrive_text_block]

[thrive_text_block color=”light” headline=”Bilder”]

Bild URL austauchen

UPDATE wp_posts
SET post_content = REPLACE (post_content, 'src=”http://www.altewebsite.com‘, 'src=”http://www.neuewebsite.com‘);

 

Umzug einer WordPress installation:

UPDATE wp_posts SET guid = replace(guid, ‚http://oldwebsite.com‘,'http://newwebsite.com‘);
UPDATE wp_posts SET post_content = replace(post_content, ‚http://oldwebsite.com‘, ‚http://newwebsite.com‘);
UPDATE wp_links SET link_url = replace(link_url, ‚http://oldwebsite.com‘, ‚http://newwebsite.com‘);
UPDATE wp_links SET link_image = replace(link_image, ‚http://oldwebsite.com‘, ‚http://newwebsite.com‘);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‚http://oldwebsite.com‘, ‚http://newwebsite.com‘);
UPDATE wp_usermeta SET meta_value = replace(meta_value, ‚http://oldwebsite.com‘, ‚http://newwebsite.com‘);

[/thrive_text_block]

[thrive_text_block color=”light” headline=”SEO”]

NoFollow Links anzeigen

SELECT * FROM wp_posts WHERE (
post_content LIKE ‚% rel=“nofollow“%‘
OR post_content LIKE ‚% nofollow%‘
OR post_content LIKE ‚%nofollow %‘
);

NoFollow entfernen:

UPDATE wp_posts SET post_content = REPLACE ( post_content, 'nofollow ‚, “ );
UPDATE wp_posts SET post_content = REPLACE ( post_content, ‚ nofollow‘, “ );
UPDATE wp_posts SET post_content = REPLACE ( post_content, ‚ rel=“nofollow“‚, “ );

[/thrive_text_block]

[thrive_text_block color=”red” headline=”Wichtig!”]

Bitte vergesst nicht zuvor ein Backup zu erstellen. Bei manchen Konstellationen ist es natürlich möglich, dass die WordPress SQL Befehle Fehler verursachen!

[/thrive_text_block]

 

In WordPress können außerdem automatische Updates aktiviert werden:

Automatische Updates bei WordPress

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>