{"id":9656,"date":"2022-11-17T16:27:36","date_gmt":"2022-11-17T16:27:36","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=9421"},"modified":"2022-11-17T16:27:36","modified_gmt":"2022-11-17T16:27:36","slug":"uploading-your-local-wordpress-mysql-site-to-a-new-hosting-cpanel-site","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/uploading-your-local-wordpress-mysql-site-to-a-new-hosting-cpanel-site\/","title":{"rendered":"Uploading Your Local WordPress MYSQL Site to a New Hosting cPanel Site"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_9656\" class=\"pvc_stats all  \" data-element-id=\"9656\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I have exported my home DBs from linux mysql, zipped them up and uploaded both the site WP content\/uploads folder and the DB sql files. To export a sql file from an active DB I use:<\/p>\n<p><span style=\"color: #0000ff;\"><span style=\"color: #00ff00;\"> stevee@localhost:\/var\/www$<\/span> mysqldump -u stevee -p ElectronicsStuff &gt; ElectronicsStuff.SQL<\/span><\/p>\n<p>The site content folder is zipped also:<\/p>\n<p><span style=\"color: #00ff00;\">stevee@localhost:\/var\/www$<\/span> <span style=\"color: #0000ff;\">zip ElectronicsStuff.zip ElectronicsStuff -r<\/span><\/p>\n<p>The are uploaded to the host site FTP dir, or wherever you like, from the File Manager section of cPanel:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9434 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/FileMgr.png\" alt=\"\" width=\"771\" height=\"316\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9435 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/upload.png\" alt=\"\" width=\"1125\" height=\"542\" \/><\/p>\n<p>Before creating any NEW DBs on your site, if you have any sites running already - back them up FIRST in case of mistakes!<\/p>\n<p>So, first you need first to have a host package that allows SSH unless your local DBs are small enough to be imported via PHPMYADMIN - the Ruby package for my host at https:\/\/krystal.uk\/ - as the base package Amethyst does not allow SSH, as I found out the hard way. Why SSH? Becuase PHPMYADMIN does not allow large file uploads without messing with PHP files, and it's easier to drop and create databases in MYSQL in case of errors - which there will be when finding your way around the cryptic structure of cPanel to get the right order of setting things up so you can import everything you need into a WordPress installation of cPanel so the system can recognise and setup the databases correctly so you can then import your home DB SQL files into MYSQL, and then upload and import your home site content of your Uploads folder into the host site's wp-content folder once the WP site has been created online.<\/p>\n<p>It took me many goes to get the order right for this whole process, which is why I'm documenting it!<\/p>\n<p>So, create the WordPress site DB and user from the Softaculous WordPress section - make sure you have the same prefix set to the same one that is currently in your home DB.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-9428\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/SoftacWP.png\" alt=\"\" width=\"1823\" height=\"459\" \/><\/p>\n<p>Expand the Advanced section to change the DB prefix details of your current home DBs wp-config.php file - e.g: <span style=\"color: #ff0000;\">$table_prefix = 'wp_xubg_';<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-9430\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/SoftacAdv.png\" alt=\"\" width=\"1921\" height=\"1033\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>You can modify you DB names, add users, change passwords and privileges in the DB section of cPanel, then you can add these new details to the wp-config.php file of the WP folder for this new install. You should have access to the site via the links in the Softaculous section, as a base WP Blog page, in its default state before you import your local DBs into the MYSQL DB via SSH later:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-9432\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/DBPage.png\" alt=\"\" width=\"1921\" height=\"1033\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>First you have to add any current users to your new WP site if you already have a site running - it may be easier to also create the same user you are going to use online in your home database before you mysqldump the home DB out, so that whem it is imported, you already have the site administrator account already created with the same login details as you set in the Softaculous section. Softaculous creates a user password for you that gets stored in the wp-config.php file thath has to be changed so that your home user can access the website version - else you may be locked out of your site with a WP White Screen of Death with no error message unless you set:<\/p>\n<p><span style=\"color: #ff0000;\">define('WP_DEBUG', true);\u00a0<\/span><\/p>\n<p>in wp-config.php.<\/p>\n<p>You can add a new user or an already existing user to your new WP database in cPanel\/Dtabase section - as you need to add DB privileges here also so that user can access the DBs from SSH\/MYSQL:<\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/AdduserDB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9460 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/AdduserDB.png\" alt=\"\" width=\"1002\" height=\"679\" \/><\/a><\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/AdduserPriv.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9462 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/AdduserPriv.png\" alt=\"\" width=\"836\" height=\"815\" \/><\/a><\/p>\n<p>Once your new user details are added into the wp-config.php file and the user given ALL privileges, you can SSH into your site and view the DBs via MYSQL command line (I use WSL Ubuntu in Windows 11 here, but Putty or other SSH method will do):<\/p>\n<p>stevee@laptop:\/mnt\/c\/Windows\/System32$ <span style=\"color: #0000ff;\">ssh -p 722 user@localhost<\/span><\/p>\n<p>After remote SSH login,\u00a0using the mysql access command:<\/p>\n<p><span style=\"color: #0000ff;\">mysql -u stevee -p<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9433 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/WSLSSH.png\" alt=\"\" width=\"808\" height=\"248\" \/><\/p>\n<p>Before you import a sql file into MYSQL, make sure you change from your current active DB to your newly created one so you don't overwrite any others! My new DB is for my ElectronicsStuff data, so:<\/p>\n<p><span style=\"color: #0000ff;\"> use steveped_ES ;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9438 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/UseES.png\" alt=\"\" width=\"808\" height=\"324\" \/><\/p>\n<p>Now I can import the already uploaded and extracted DB.sql files from the public_ftp folder where I stored them:<\/p>\n<p><span style=\"color: #0000ff;\">source \/public_ftp\/ElectronicsStuff.SQL ;<\/span><\/p>\n<p>You don't have root privileges to restart mysql after the import, so I assume there are auto checks running on the host VMs to always restart DBs after any changes? Normally, at home, if you have sudo privileges:<\/p>\n<p><span style=\"color: #0000ff;\">service mysql restart<\/span><\/p>\n<p>Now the remote WP database has had you home SQL file imported, you can try to access your site. If you cannot, due to WP White Screen, Database connection errors etc. check that you have the correct login details in your site's wp-config file. There is a usually an example file created with a new WP install to refer to:<\/p>\n<p>The key sections to fill change if neccesary, to your details are in red:<\/p>\n<pre class=\"lang:default decode:true\">define( 'DB_NAME', '<span style=\"color: #ff0000;\">database_name_here<\/span>' );\n\n\/** Database username *\/\ndefine( 'DB_USER', '<span style=\"color: #ff0000;\">username_here<\/span>' );\n\n\/** Database password *\/\ndefine( 'DB_PASSWORD', '<span style=\"color: #ff0000;\">password_here<\/span>' );\n\n\/** Database hostname *\/\ndefine( 'DB_HOST', 'localhost' );\n\n\/** Database charset to use in creating database tables. *\/\ndefine( 'DB_CHARSET', 'utf8' );\n\n\/** The database collate type. Don't change this if in doubt. *\/\ndefine( 'DB_COLLATE', '' );\n\n\/**\n * WordPress database table prefix.\n *\n * You can have multiple installations in one database if you give each\n * a unique prefix. Only numbers, letters, and underscores please!\n *\/\n$table_prefix = '<span style=\"color: #ff0000;\">wp_<\/span>';<\/pre>\n<p>If all has gone well, your site should be web visible and you should be able to login to your site's admin page:<\/p>\n<p><span style=\"color: #3366ff;\">https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-admin\/<\/span><\/p>\n<p>I had SO many attempts before I became familiar enough with the process that my site worked AND I could log in to Admin.<\/p>\n<p>Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_9656\" class=\"pvc_stats all  \" data-element-id=\"9656\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I have exported my home DBs from linux mysql, zipped them up and uploaded both the site WP content\/uploads folder and the DB sql files. To export a sql file from an active DB I use: stevee@localhost:\/var\/www$ mysqldump -u stevee -p ElectronicsStuff &gt; ElectronicsStuff.SQL The site content folder is zipped also: stevee@localhost:\/var\/www$ zip ElectronicsStuff.zip ElectronicsStuff <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/uploading-your-local-wordpress-mysql-site-to-a-new-hosting-cpanel-site\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 Uploading Your Local WordPress MYSQL Site to a New Hosting cPanel Site<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-9656","post","type-post","status-publish","format-standard","hentry","category-post"],"a3_pvc":{"activated":true,"total_views":6,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/9656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=9656"}],"version-history":[{"count":0,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/9656\/revisions"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=9656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=9656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=9656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}