‫All right guys.
‫So there's going to be a time where you need to deploy this or if you want to if you want to work on
‫it on another machine, you're going to need your data and you're not going to want to just recreate
‫the database, recreate all the tables, the tables and the fields and the field types, and then add
‫your data.
‫So I'm going to show you how to just export everything.
‫So you have one single dot SQL file that has all the queries that you need to run to create your database
‫from scratch, okay, with all the stuff included.
‫So and we can do this from MySQL workbench.
‫So I'm going to go you guys can't see my main menu but there's a server option.
‫And then in server there's this data export option.
‫And it will open up something like this.
‫And then I'm going to select the work database and make sure the two tables are selected.
‫And it shows you right here where this dump file is going to is going to be output.
‫So make sure you take note of that.
‫Mine's in my home folder dumps and then this file folder here.
‫And then I'm not going to include the create schema.
‫I'm going to add that myself.
‫Because what it's going to do is give us two files listings dot SQL and users dot SQL.
‫And I want to take those and combine them into one single file where we create the database and then
‫add those tables and the data.
‫So let's go ahead and click Start Export.
‫And I'm just going to say continue anyway for that.
‫And then it says export completed.
‫So now you can open up the output folder which for me is is my home folder.
‫So I'm going to bring that over.
‫Well it's my home folder and then dumps and then this dump folder.
‫And you can see I have work open listings SQL and work open users.
‫So I want to create a new text file to kind of create this in.
‫So I'm going to just open up Sublime Text for that, which is what I usually use for like basic text
‫files and let's save this as a dot SQL file so that we have the the highlighting.
‫So I'm just going to save it on or in my desktop.
‫And I'm going to call it I know you guys can't see this whole thing but I'm going to call it work Opia
‫dot SQL.
‫Yeah.
‫Okay, so from here I'm actually going to just type in, I'm going to put a comment here with two hyphens
‫and say create the we'll say create the word copia.
‫Database.
‫And we're going to do that with create database.
‫And we want to say if not exists.
‫If it already exists then we're not going to touch it.
‫So if not exists we're copia.
‫And end it with a semicolon.
‫And then we want to use that database.
‫So let's say use work ops semicolon.
‫Now I want to open up the users file that was exported.
‫So let me just bring that over and I'm going to grab everything in here.
‫So select all and copy and then we're going to paste that in.
‫So what this is doing is creating the table.
‫First it's going to drop it.
‫If it exists then it will create it.
‫It'll add all the fields primary key.
‫And then it will insert the data that we exported okay.
‫Now I also want to do the listings.
‫So let's go to the listings file now.
‫And if I bring that over, I'm going to just grab everything in here, copy it, close it, and then
‫down at the very bottom here we're going to paste that in.
‫And this will do the same thing.
‫Except it's it's it's doing the listings table now.
‫And it will insert all the data as well.
‫All right.
‫So just kind of a summary.
‫It will create the database.
‫If it doesn't exist use it.
‫Create the users table.
‫Import the data.
‫Create the listings table.
‫Import the data.
‫So you can save this file and just keep it so that you can run this wherever you want to create the
‫the database.
‫And I'm going to do it right in workbench.
‫So I'm going to just select all and copy.
‫And then in workbench I'm going to go to one of these query tabs.
‫Let's close this up.
‫And in this query tab, I'm just going to paste everything in, except I'm going to change the name
‫of the database because I already have work ops.
‫So I'll just say work Opia two and then use work Opia two.
‫And then to run this we can either do command or control enter, or we can hit the lightning bolt.
‫And then over here we want to refresh.
‫So this little refresh icon and you'll see now we have work Opia two.
‫We have the tables.
‫If I say select rows from the listings we have all of our listings.
‫All right.
‫So we just set up our database and all the tables and all the data from this one.
‫Or I should say these many queries that are now in that one work Opia dot SQL file.
‫Okay.
‫So I just wanted to show you guys how to do that.