Created
February 11, 2020 15:22
-
-
Save PatricNox/a4c3801f638ed0447089a561e35f8493 to your computer and use it in GitHub Desktop.
Database Init script for Wordpress sites through Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This file needs to be executed once a new database is imported. | |
# What this does, is updating database to tell wordpress that the site should | |
# be runned on localhost. | |
# | |
## Supress warning. | |
export MYSQL_PWD=wordpress | |
## Tell wordpress that the domain is localhost. | |
## Edit CURRENTDOMAIN to the imported domain. | |
mysql --host 0.0.0.0 -u wordpress wordpress -e " | |
-- Update domain to localhost. | |
UPDATE wi1_options SET option_value = replace(option_value, 'CURRENTDOMAIN', 'http://localhost') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wi1_posts SET guid = replace(guid, 'CURRENTDOMAIN','http://localhost') ; | |
UPDATE wi1_posts SET post_content = replace(post_content, 'CURRENTDOMAIN', 'http://localhost') ; | |
UPDATE wi1_posts SET post_excerpt = replace(post_excerpt, 'CURRENTDOMAIN', 'http://localhost') ; | |
UPDATE wi1_postmeta SET meta_value = replace(meta_value, 'CURRENTDOMAIN', 'http://localhost'); | |
-- Create Admin account for Dev. | |
SET @role := 'a:1:{s:13:\"administrator\";b:1;}'; | |
INSERT INTO \`wi1_users\` (\`ID\`, \`user_login\`, \`user_pass\`, \`user_nicename\`, \`user_email\`, \`user_status\`, \`display_name\`, \`user_registered\`) VALUES ('1', 'admin', MD5('admin'), 'admin', '[email protected]', '0', 'admin', '2020-01-20'); | |
INSERT INTO \`wi1_usermeta\` (\`umeta_id\`, \`user_id\`, \`meta_key\`, \`meta_value\`) VALUES (NULL, '1', 'wi1_capabilities', @role); | |
INSERT INTO \`wi1_usermeta\` (\`umeta_id\`, \`user_id\`, \`meta_key\`, \`meta_value\`) VALUES (NULL, '1', 'wi1_user_level', '10'); | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wi1_ prefix most likely needed to be changed to yours. Same as CURRENTDOMAIN strings