Score:-1

Wordpress Mysql Database File - Ubuntu 20.04

jp flag

I installed Wordpress on Ubuntu 20.04 using the following link:

https://ubuntu.com/tutorials/install-and-configure-wordpress#1-overview

Then, I created a website on localhost. Now I need to migrate it to a web hosting to make it live. I did not find the database in var/lib/mysql/my_database_name. Could you tell me where I can find the database of Wordpress? I do not have installed phpmyadmin

Thank you

waltinator avatar
it flag
Telling us which remote procedure (RP) you "followed" doesn't help us help you for N reasons: 1) It's remote. Will the link exist tomorrow? 2) Reading the RP doesn't tell us how accurately you "followed" it. Did you suffer typos or missed lines? We have. 3) Reading the RP omits the error messages **you** got on **your system**. These error messages (and the commands that caused them) are key elements in any diagnosis.
Score:1
in flag

You really do not want to move just the MySQL database file from one server to another. MySQL really doesn't like that, and it's a complicated process to get right even for people who use databases all day long.

What you are looking for is a database export, which you can create from the command line like this:

sudo mysqldump {database} > {filename}

So, if your WordPress database is called wordpress, and you want the file to be called export.sql, then you would do something like this:

sudo mysqldump wordpress > export.sql 

So long as you are using the stock version of MySQL that is available for Ubuntu, and so long as you've not made a mess of the permissions structure by tampering with root, there is no need to enter a username or password while doing this. Anyone who has sudo permissions on a server is considered an administrator.

After copying the export file to the new server, you can import it like so:

sudo mysql {database} < {filename}

Note that this is using mysql rather than mysqldump, and also note that there is a < instead of a >. These are important. As before you will want to replace {database} and {filename} with the appropriate values.

Be sure that the database you're importing the data into exists before trying to import the data.

However ...

Based on the way the question is written, and based on many years of experience with WordPress-powered sites, it would be better for you to not migrate the database.

WordPress has a lot of domain-specific and filesystem-specific settings stored in its database that can often result in a rather large headache for people who would like to migrate data from one place to another. While all of this can be fixed with additional SQL queries, it's really not something that most people want to do.

A simpler solution would be to simply install WordPress on the live web server and configure everything from scratch. If you have a bunch of posts that you would like to bring over, then doing a copy/paste between the two admin pages would be the simpler way to go, especially if you have embedded content such as images, audio, video, and the like.

alvin77 avatar
jp flag
Thank you so much for your explanation. It was very helpful. I successfully exported my SQL Wordpress database. I have several pages with text and images to import. I will install Wordpress on my web hosting provider and then use a plugin for Wordpress migration. On the other hand I saw that you can import your SQL database in Wordpress using phdmyadmin. Maybe I will try both methods. Best Regards, Andrea
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.