Skip to content

Instantly share code, notes, and snippets.

View rafalosinski's full-sized avatar

Rafał Osiński rafalosinski

View GitHub Profile
SET @old_url='old.domain';
SET @new_url='new.domain';
UPDATE wp_options SET option_value = replace(option_value, @old_url, @new_url) WHERE option_name = 'home' OR option_name = 'siteurl'
UPDATE wp_posts SET guid = replace(guid, @old_url, @new_url)
UPDATE wp_posts SET post_content = replace(post_content, @old_url, @new_url)
UPDATE wp_postmeta SET meta_value = replace(meta_value, @old_url, @new_url)
@rafalosinski
rafalosinski / change-url.php
Last active June 22, 2017 21:29
Change WordPress URL with mysqli & php
<?php
include 'wp-config.php';
$servername = DB_HOST;
$username = DB_USER;
$password = DB_PASSWORD;
$dbname = DB_NAME;
$old_url = "";
$new_url = "";
@rafalosinski
rafalosinski / dump.php
Last active June 22, 2017 21:09
DUMP WordPress SQL DB
<?php
include 'wp-config.php';
$DBUSER = DB_USER;
$DBPASSWD = DB_PASSWORD;
$DATABASE = DB_NAME;
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
$mime = "application/x-gzip";
@rafalosinski
rafalosinski / create-user.sql
Last active November 21, 2017 17:39
Create WordPress Admin User from SQL (PHPMYADMIN)
SET @user_login='john_doe';
SET @user_pass=MD5('YOUR_HARD_PASSWORD');
SET @user_nicename=@user_login;
SET @user_email='john.doe@example.com';
SET @user_url='http://example.com/';
SET @display_name='John Doe';
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES (null, @user_login, @user_pass, @user_nicename, @user_email, @user_url, CURRENT_TIMESTAMP(), '', '0', @display_name);
SET @last_id=LAST_INSERT_ID();
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, @last_id, 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');