Need up to 30 seconds to load.
hello and welcome back to another my SQL
tutorial so here we're going to learn
how to backup a MySQL database an
important task so here we're going to be
utilizing PHP myadmin and I'll also show
how to backup and restore using SQL okay
so inside of PHP my admin so you make
sure you got your server turned on and
then it's a localhost forward slash PHP
my admin' inside of here I'm going to
select my database I want to backup and
then just select export so from here I'm
just gonna select the format I want to
export my database as so if I know that
I'm going to go into export this
database and then import it back into
another MySQL database system then SQL
would be a good choice you can see all
the other options that might be
available so SQL typically the default
choice and press go and then I just need
to decide where I want to save this so
if we just have a look at the file you
can see that this is a PHP myadmin SQL
dump
you'll notice that comments are are made
and we've - so note in a comment and
then we have all different aspects here
set time and then we have database so
this again is commented so if you were
going to recreate this SQL or import
this SQL here you'd have to actually
generate your own database so this isn't
going to actually generate a database
this is only going to generate the data
inside a database so great table so you
can see the commands so we create a new
table and then we insert some values so
let's go back now and try and import
this so this is in my downloads I'm just
going to put this onto my
drink onto my desktop okay so let's now
delete this database I'm double click
and drop this database okay so like I
said you can't just run the script if I
try and import this script from my
desktop and then I click on go you can
see there's an error because it's
there's no database selected so when you
use the export like this you'll need to
create a database luckily it tells you
what database you need to create if you
want to replicate the system so here we
just need to then go back to home
Slick's like new user stats press create
make sure then we select the database
and then import the file that we just
exported so from here just press GO and
now we have our database recreated so
how can this be replicated using
commands so if you're not running PHP
myadmin
so inside of the xampp control panel we
can access the shell and from here we
can access the database using the
command line so here's what we need we
need to first go into the command prompt
or the shell and inside of here we've
got my SQL dump so we're gonna do MySQL
dump we're gonna select the database you
want to dump and then create a new SQL
file like we did with PHP my admin' so
first of all we type in my SKU I'll dump
or this command or these codes this code
will be in the description below the
video and we have double - user equals
root don't want - password there is no
password for this database that logs us
in and then basically we select the
database we want to backup and then we
have a write Chevron and then we name
the file we want to make and then the
file extension so this is going to make
a backup like we did with PHP myadmin
the date is here or their file is going
to be stored in the root file of where
xampp is installed so run that if I go
back into my xampp folder on the c drive
you'll find if i scroll down there's a
new file here good user stats dot SQL
okay so that's where it's saved so just
get rid of that so now if I want to
restore it well les first of all let's
just go into the database so we can go
into the actual database system typing
in MySQL user it goes root we don't need
all of this but I'm just gonna follow
this pattern password equals nothing so
I mean so now inside of a database I can
now obviously show the databases okay so
that's all the databases so now I want
to delete user stats so how do I delete
user stat stat so I just type in word
drop database and then define what I
want to drop or delete okay and there we
go so now that's dropped so I can just
check that okay so now a database has
been dropped I'm just going to quit this
and then close that so imagine we now
want to recreate this so let's go back
into the shell and now what we want to
do is obviously we need to first build
the database so we can do that one or
two ways we could go into the system and
type in what we need user stats or we
could just do it directly from here
so here we're going to type in this
command so again we log in and then we
creates a database called user stats
there we go so now we have a database
called user stats so what we need to do
now is take our file and run the file
so use a root password again nothing so
here we've got data base is going to be
user stats so we select the database we
want to recreate the data for and then
we select the SQL file that we created
earlier
so that's going to import it into this
database and recreate the database as it
was originally and there we go so we'll
just close that and have a look and you
can see that we've got a new database
called user stats and everything is back
as it was ok ok so there we go
we now know how to backup or might
create a very simple backup
utilizing PHP myadmin and utilizing SQL