MySQL Presentation
MySQL Presentation
for
Oracl e & MS D BA
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 1
Objectives
• Introduction MySQL the Company
• Architecture of MYSQL
• The Basic
• Configuration of MySQL
• Security
• User Management
• Backup and Restore
• Troubleshooting Step
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 2
The World’s Most Popular
Open Source Database
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 3
MySQL Database Server – the 10 million!
Free
Community Edition
Available under GPL
Software tested by
Community + basic
MySQL AB testing
Release early & often
cycle (3 to 4 weeks)
Bleeding edge
No maintenance SLA
Not supported
No ISV certification
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 4
MySQL Network
Free Supported
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 5
Yahoo!
Application
MySQL powers over 200 Yahoo!
properties around the world including
Yahoo! Finance with 260 million rows.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 6
MYSQL Architecture
indows™ : my.ini
C:\Program Files\MySQL\MySQL Server x.y\my.ini
Linux : my.cnf
/etc/my.cnf or /etc/mysql/my.cnf
/whereYouInstalledMySQL/data/my.cnf (server-specific options)
(@localstatedir@ for this installation)
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 7
Let’s st art working
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 8
The Basic
Connecting to and disconnecting from Server
shell > mysql –h localhost –u user –p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67-community-nt MySQL Community
Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 9
The Basic
•Creating and Using Database
mysql> create database tutorial;
Query OK, 1 row affected (0.00 sec)
mysql> use tutorial;
Database changed
•Create a table
Shell>mysql -h localhost -u root -p tutorial
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.67-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create table cheese ( Name varchar(15) not null, weight int not null,
-> primary key(name));
Query OK, 0 rows affected (0.13 sec)
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 10
System File & Table
Configuration files
Windows™ : my.ini
C:\Program Files\MySQL\MySQL Server x.y\my.ini
Linux : my.cnf
/etc/my.cnf or /etc/mysql/my.cnf ( Global options)
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 11
Command -Start & Stop Server
In Window
Start MySql server:
c:\mysql\bin\mysqld-nt --standalone - You can leave the DOS window open or
close it.
Stop MySql server:
c:\mysql\bin\mysqladmin shutdown - This will shutdown the server.
In Linux
To start MySQL server
/etc/init.d/mysqld start
To stop MySQL server
/etc/init.d/mysqld stop
To check the status
/etc/init.d/mysqld status
Or
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 12
Running external script
Manually:
mysql -u root -p -P 3306
create myDatabase
By a SQL script:
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 13
Security setting
• Set the root password
– The default installation of MySQL leave the root
password blank. So the first step to do when we login
is
Shell>mysql –uroot mysql
mysql> update user set password = PASSWORD('abc123') where
user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 14
Security setting
• List anonymous users:
• SELECT Host, User FROM mysql.user WHERE
User='';
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 15
Security setting
• MySQL uses Access Control Lists (ACLs) for all
connections, queries, and other operations that a user may
attempt to perform. The ACLs are composed of tables which
are used to determine privilege.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 16
Security setting
• The server uses the user, db, and host tables in the mysql
database at both stages of access control.
• For the second stage of access control, the server may, if the
request involves tables, additionally consult the tables_priv and
columns_priv tables.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 17
User Management
• The server uses the user, db, and host tables in the mysql
database at both stages of access control.
• For the second stage of access control, the server may, if the
request involves tables, additionally consult the tables_priv and
columns_priv tables.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 18
Security setting
• Adding Users. MySQL users and their privileges are normally
created with GRANT statements. You may however edit the user
table manually with INSERT statements. Below are examples of
each.
Using GRANT statements.
shell> mysql --user=root mysql mysql> GRANT ALL PRIVILEGES ON *.* TO
cheese@localhost -> IDENTIFIED BY 'some_pass' WITH GRANT OPTION; mysql> GRANT
RELOAD,PROCESS ON *.* TO admin@localhost; mysql> GRANT USAGE ON *.* TO
dummy@localhost;
Using INSERT statements.
shell> mysql --user=root mysql mysql> INSERT INTO user
VALUES('localhost','cheese',PASSWORD('some_pass'), ->
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); mysql> INSERT INTO user SET
Host='localhost',User='admin', -> Reload_priv='Y', Process_priv='Y'; mysql> INSERT INTO
user (Host,User,Password) -> VALUES('localhost','dummy',''); mysql> FLUSH PRIVILEGES;
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 19
Mysqldump-backup
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 20
Basic MySQL syntax (i)
Use the "mysql" Database
use mysql;
Show a list of Tables in the Database
show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 21
Basic MySQL syntax
•SHOW DATABASES;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
USE database_name;
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 22
Summary useful command
•mysql -u root -p -P 3306
mysql> status
mysql> show status ; (<=> mysqladmin -u root -p extended-status)
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database 24