hi guys welcome to this mysql beginners tutorial. And in this tutorial I will be teaching
you the basics of mysql like creating a database, reading from a database
updating a databse and deleting a database
and for this purpose I will be using only mysql command line so for those
of you who use phpmyadmin i will be uploading some more videos ..
..time but for now i will be using the mysql command line
so let's get started. First of all i want you to browse through to your folder
where you have installed mysql
i have it installed inside my D drive...
..go to my D drive
my program files
and i have installed xampp so my mysql is intalled
inside xampp
so i will go inside
inside...mysql
and whatever applications of mysql I have i have it inside my bin folder
so while using mysql command line to connect with mysql databse i have to
browse through to the bin folder and then connect to my database
so just go ahead and open up your command prompt
uh... type in cmd
and inside here
I will do cd slash
to return to root folder
and here I will change the drive to D. So I will write
D colon and then press enter
and inside here I will go to program files
and here I will go to xampp
then to mysql
then to bin
so inside my bin folder i have all my applications of mysql
and now i will connect to my mysql database
so now just pay attention. How to connect to a mysql database
you have to write mysql
if you have installed any packages containing mysql with all the default
settings, then your username will be root
and your password will be nothing
so here you have to use your username and password to connect with your database
so you have to write mysql
then minus u
and you have to type in your username ...root by default
minus password
password is nothing so I will leave it
then you have to type in minus hostname
in our case
hostname is one twenty seven
point zero point zero point one
now i will press enter
here it will ask me to enter password. i don't have a password so
i'will just
press enter and
it says welcome to mysql moniter. So we are now connected to mysql
database now whatever operations i want to perform in my mysql database
we can perform
so first of all mysql consists of a series of databases so
first of all what we will do is ask mysql to show
whatever databases it already has
so i will write
show
databases
and every command in mysql
ends with a semicolon. so we have to
write semicolon at the end and press enter
so it shows that
i already have
one two three four five databases on my mysql server
we want to create a new database so i will just write
create
database
and i will name my database as userlogin
and add semicolon and press enter
it says query OK! And now our databse is created, now we have to go into that
database
so we will write use
user
login
now it says database changed
so we are inside userlogin...opearations we do now it will
clearly be reflected inside userlogin
Now i want to tell u something.Every database in mysql consists of a
series of tables
and each tables consist of rows and columns
so we can say that
a database is nothing but a series of tables
which stores some information
so we will see first if userlogin contains any tables, so i will write
show
tables
and it says empty set means
there are no tables present, because we haven't entered any table.. so
we have to create a table first
so i will just create a table
i will name my table as
user
now i have to determine what parameters my table will have
so we will just here pause for a minute and think about it
so i will go ahead and open up my notepad++
we can sketch aout
whatever parameters we will have.First of all we will have an id
and then the second parameter will be
username
and third parameter will be password
and fourth parameter suppose we will have email
so these are the four different parameters with which we
will create our table
so i will now just close it.
First Parameter - id, it will be a integer type
of 11 digits. It will close to 10 billion so it will be enough
it will be unsigned
it will be auto_increment means automatically it will go on increasing.
and it will be
our primary key
and it will not be null.
our second parameter is username
it will be a Varchar
suppose the limit is twenty five characters
and it will be not null.
again suppose
next parameter is password
it will be a Varchar also
and limit is twenty five
and it will also be not null.
and again last is email
and it will be a Varchar also
and it will be supposed 40
and it will also be not null.
Now I will
end my bracket
press semicolon and press enter.
It says Query OK, 0 rows affected.
It means our table got created.
now we can
see the table by
typing in
show
tables
So, it says there is a table in our database
which is named as user
and we can see the details of table by typing in
describe
user
so here it comes
our id is an integer of 11 digits, it is unsigned, it will not be null
and it is our primary key
and it is auto_increment type.
Username is Varchar of limit 25 characters and password is Varchar
of limit 25 characters
email is varchar of 40 characters
this is an empty table having no data at all, only the parameters are defined.
now in the next tutorial we will enter the data into this table.