Documente Academic
Documente Profesional
Documente Cultură
1 Table of Contents:
Lesson 1 : Showing the basics
Lesson 2 : Creating Tables & DBs
Lesson 3 : Adding / Updating / Displaying data
Lesson 4 : Backing up a DB
Lesson 5 : Restoring a DB
Lesson 6 : Destruction of tables and DBs
Lesson 7 : Config's
Lesson 8 : Self Exploration
Lesson 9 : Challenge
Lesson 1 : Showing the basics
Showing databases.
mysql> show databases;
Utilizing a Database using the "mysql" database as an example.
mysql> use mysql;
Showing tables in our example database "mysql".
mysql> show tables;
We will now describe the table "user" in the "mysql" database.
mysql> desc user;
Showing users in the "mysql" in the "user" table.
mysql> select * from user;
To Select the Host,User,and Password
mysql> select host, user, password from user;
If you describe "user" you will see these are 3 feilds listed in here.
This is how you can tell what your able to select.
mysql> desc user;
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Host
| char(60)
| NO
| PRI |
|
|
| User
| char(16)
| NO
| PRI |
|
|
| Password
| char(41)
| NO
|
|
|
|
descr char(255),
Login int(10),
SignupDate DATETIME NOT NULL,
SignupUnix TIMESTAMP NOT NULL
);
For other DataTypes view my supplemental documentation:
MySQL_DataType_supplemental.pdf
View your new table!
mysql> desc exampletable;
mysql> select * from exampletable;
Empty set (0.00 sec)
Yep Empty set = No data in table. We will come back to this later,
and add data!
We will now Creating a user for our DB.
mysql> grant all on exampledb.* to 'exampleuser'@'localhost' identified
by 'test' with grant option;
Above allows you too effectively have root over the exampledb, but what
if you need a user to have limited access? We are going to grant basic
priviledges.
mysql> grant Select,Insert,Update on exampledb.*
to 'exampleuser1'@'localhost' identified by 'test1' with grant option;
Above creates a user with read, write, and update priviledges only.
To Revoke priviledges, take a look at this page and try to figure it out :)
http://dev.mysql.com/doc/refman/5.0/en/drop-user.html
Lesson 3 : Adding / Updating / Displaying data
Now we are going Inserting values or add information to our database.
mysql> insert into exampletable (user,descr,login) values ('TheDude','The
Dude is a user',1);
mysql> select * from exampletable;
+---------+--------------------+-------+---------------------+---------------------+
| user
| descr
| Login | SignupDate
| SignupUnix
|
+---------+--------------------+-------+---------------------+---------------------+
| TheDude | The Dude is a user |
1 | 0000-00-00 00:00:00 | 2011-03-13 05:17:46 |
+---------+--------------------+-------+---------------------+---------------------+
= /var/log/mysql/error.log
We also want to verify that we can access this mysql server from the
outside. We will have to verify the bind-address is not set to local host or
127.0.0.1 :
#bind-address
= 127.0.0.1
#>
#>
#>
#>
#>
sudo
sudo
sudo
sudo
sudo
mysqlcheck -A
mysqloptimize -A
mysqlcanalyze -A
mysqlreport
mysqlshow
Lesson 9 : Challenge
Installing wordpress :D
HINT:
http://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install