介紹 元智大學電機工程所 碩士班一年級 蕭觀華 學號 :917152. MySQL 介紹大綱 What is MySQL ? How to install on Linux Tutorial Introduction Database Administration MySQL Perl API Q&A.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

How to Use MySQL CS430 March 18, SQL: “Structured Query Language”—the most common standardized language used to access databases. SQL has several.
CS34311 CS3431 – Database Systems I Project Overview Murali Mani.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Databases with PHP A quick introduction. Y’all know SQL and Databases  You put data in  You get data out  You can do processing on it very easily 
Session 5: Working with MySQL iNET Academy Open Source Web Development.
7/8/05MySQL David Lawrence1 David Lawrence, JLab An introduction for the novice.
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
INTERNET APPLICATION DEVELOPMENT For More visit:
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
SQL HW1 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Python MySQL Database Access
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 15. General MySQL Administration Topics: –Securing a New MySQL Installation –MySQL Server.
LIS651 lecture 6 mySQL Thomas Krichel
Introduction to MySQL Lab no. 10 Advance Database Management System.
Introduction to Internet Databases MySQL Database System Database Systems.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
Introduction to MySQL MySQL Overview by Ray Williams CS 320/565 Marymount University.
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
1 MySQL Using Databases with PHP or Perl Scripts:.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 11. The Perl DBI API - Part II Topics: – Perl DBI interface to MySQL.
Apache, MySQL and PHP Installation and Configuration Chapter 2 MySQL Installation and Configuration.
SQL has several parts: Major ones: DDL – Data Definition Language {Defining, Deleting, Modifying relation schemas} DML – Data Manipulation Language {Inserting,
PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
Database server Campus-Booster ID : ****** Copyright © SUPINFO. All rights reserved MySQL.
What is MySQL? MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, Many.
Chungbuk HRDI of KCCI PhD Kang,Won-Chan PHP Programming (MySQL)
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
VIRTUAL HOSTING WITH PureFTPd And MYSQL (Quota And Bandwidth Management) BY Odoh Kenneth Emeka Sun Yu Patrick Appiah.
Mysql YUN YEO JOONG. 1 Connecting to and Disconnecting from the Server 1 Connecting to and Disconnecting from the Server shell> mysql – h host -u user.
MySQL API( c ) & SQL2 강동훈.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Lab 3.21 MySQL Database Lab Developing the Tools May 5 th, 2004 Montréal, Québec Dominik Gehl Hôpital Ste-Justine, Montréal.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 3 – MySQL – Statements.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
Fundamental of Databases
Introduction to MySQL.
Introduction to MySQL.
Basics on DB access Elke A. Rundensteiner.
Perl Database – Just Enough
ISC440: Web Programming 2 Server-side Scripting PHP 3
Chapter 8 Working with Databases and MySQL
MSIS 655 Advanced Business Applications Programming
CS3220 Web and Internet Programming SQL and MySQL
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
MySQL Database System Installation Overview SQL summary
Presentation transcript:

介紹 元智大學電機工程所 碩士班一年級 蕭觀華 學號 :917152

MySQL 介紹大綱 What is MySQL ? How to install on Linux Tutorial Introduction Database Administration MySQL Perl API Q&A

What is MySQL ? MySQL, the most popular Open Source SQL database, is developed, distributed and supported by MySQL AB.

How to Install on Linux Quick Standard Installation of MySQL ( by RPM ) Installing a MySQL Source Distribution

Quick Standard Installation of MySQL How to get RPM file: Go to here : To see all files in an RPM package, run: shell> rpm -qpl MySQL-VERSION.i386.rpm To perform a standard minimal installation, run: shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm To install just the client package, run: shell> rpm -i MySQL-client-VERSION.i386.rpm

Installing a MySQL Source Distribution How to get Source packages : shell> groupadd mysql shell> useradd -g mysql mysql shell> gunzip < mysql-VERSION.tar.gz | tar -xvf shell> cd mysql-VERSION shell>./configure --prefix=/usr/local/mysql shell> make shell> make install shell> scripts/mysql_install_db shell> chown -R root /usr/local/mysql shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysql shell> cp support-files/my-medium.cnf /etc/my.cnf shell> /usr/local/mysql/bin/safe_mysqld --user=mysql &

MySQL Data environment on Linux RPM: The RPM places data in `/var/lib/mysql'. The RPM also creates the appropriate entries in `/etc/rc.d/' to start the server automatically at boot time. Source: The data in `/usr/local/var/mysql'. We will creates the appropriate entries in `/etc/rc.d/init.d/rc.local' to start the server automatically at boot time. write this line in `/etc/rc.d/init.d/rc.local' file: /usr/local/mysql/bin/safe_mysqld --user=mysql &

MySQL Tutorial Introduction Connecting to the Server Entering Queries Creating and Using a Database Getting Information About Databases and Tables

Connecting to the Server shell> mysql -h host -u user -p Enter password: ******** The ******** represents your password; enter it when mysql displays the Enter password: prompt. If that works, you should see some introductory information followed by a mysql> prompt: shell> mysql -h host -u user -p Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 459 to server version: a-log Type 'help' for help. mysql>quit

Entering Queries Here's a simple command that asks the server to tell you its version number and the current date. Type it in as shown here following the mysql> prompt and press Enter: mysql> SELECT VERSION(), CURRENT_DATE; | VERSION() | CURRENT_DATE | | a-log | | row in set (0.01 sec) mysql>

Creating and Using a Database(1) CREATE DATEBASE sample_DB USE sample_DB You can create the example table as: CREATE TABLE shop ( article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL, dealer CHAR(20) DEFAULT '' NOT NULL, price DOUBLE(16,2) DEFAULT '0.00' NOT NULL, PRIMARY KEY(article, dealer)); INSERT INTO shop VALUES (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69), (3,'D',1.25),(4,'D',19.95);

Creating and Using a Database(2) Okay, so the example data is: mysql> SELECT * FROM shop; | article | dealer | price | | 0001 | A | 3.45 | | 0001 | B | 3.99 | | 0002 | A | | | 0003 | B | 1.45 | | 0003 | C | 1.69 | | 0003 | D | 1.25 | | 0004 | D | |

Getting Information About Databases and Tables(1) mysql> SELECT DATABASE(); | DATABASE() | | menagerie | mysql> SHOW TABLES; | Tables in menagerie | | event | | pet |

Getting Information About Databases and Tables(1) mysql> DESCRIBE pet; | Field | Type | Null | Key | Default | Extra | | name | varchar(20) | YES | | NULL | | | owner | varchar(20) | YES | | NULL | | | species | varchar(20) | YES | | NULL | | | sex | char(1) | YES | | NULL | | | birth | date | YES | | NULL | | | death | date | YES | | NULL | |

Database Administration Configuring MySQL MySQL User Account Management

Configuring MySQL(1) `my.cnf' Option Files :/etc/my.cnf Here is a typical global option file: [client] port=3306 socket=/tmp/mysql.sock [mysqld] port=3306 socket=/tmp/mysql.sock set-variable = key_buffer_size=16M set-variable = max_allowed_packet=1M [mysqldump] quick

Configuring MySQL(2) Here is typical user option file: [client] # The following password will be sent to all standard MySQL clients password=my_password [mysql] no-auto-rehash set-variable = connect_timeout=2 [mysqlhotcopy] interactive-timeout

MySQL User Account Management Global level Global privileges apply to all databases on a given server. These privileges are stored in the mysql.user table. (user logon to mysql server) Database level Database privileges apply to all tables in a given database. These privileges are stored in the mysql.db and mysql.host tables. Table level Table privileges apply to all columns in a given table. These privileges are stored in the mysql.tables_priv table. Column level Column privileges apply to single columns in a given table. These privileges are stored in the mysql.columns_priv table.

User Account Management (1) shell> mysql --user=root mysql mysql> INSERT INTO user (Host,User,Password) -> VALUES('localhost','custom',PASSWORD('stupid')); mysql> INSERT INTO user (Host,User,Password) -> VALUES('server.domain','custom',PASSWORD('stupid')); mysql> INSERT INTO user (Host,User,Password) -> VALUES('whitehouse.gov','custom',PASSWORD('stupid'));

User Account Management (2) mysql> INSERT INTO db -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> Create_priv,Drop_priv) -> VALUES -> ('localhost','bankaccount','custom','Y','Y','Y','Y','Y','Y'); mysql> INSERT INTO db -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> Create_priv,Drop_priv) -> VALUES -> ('whitehouse.gov','expenses','custom','Y','Y','Y','Y','Y','Y'); mysql> INSERT INTO db -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> Create_priv,Drop_priv) -> VALUES('%','customer','custom','Y','Y','Y','Y','Y','Y'); mysql> FLUSH PRIVILEGES;

MySQL Perl API DBI with DBD::mysql DBI is a generic interface for many databases. That means that you can write a script that works with many different database engines without change. You need a DataBase Driver (DBD) defined for each database type. For MySQL, this driver is called DBD::mysql. For more information on the Perl5 DBI, please visit the DBI web page and read the documentation:

Perl DBI with DBD::mysql Methods Method : Description Connect : Establishes a connection to a database server. Disconnect : Disconnects from the database server. Prepare : Prepares a SQL statement for execution. Execute : Executes prepared statements. Do : Prepares and executes a SQL statement. Quote : Quotes string or BLOB values to be inserted. fetchrow_array : Fetches the next row as an array of fields. fetchrow_arrayref : Fetches next row as a reference array of fields. fetchrow_hashref : Fetches next row as a reference to a hashtable. fetchall_arrayref : Fetches all data as an array of arrays. Finish : Finishes a statement and lets the system free resources. Rows : Returns the number of rows affected. data_sources : Returns an array of databases available on localhost.

Q & A