Title: MySQL
1MySQL
????? http//debut.cis.nctu.edu.tw/ching
2General Information
- The MySQL
- delivers a fast, multi-threaded, multi-user, and
robust SQL database server - SQL? Structured Query Language
- is intended for mission-critical, heavy-load
production - MySQL is a trademark of MySQL AB
- Dual license
- Open Source / Freeware software product under GNU
- Purchase a standard commercial license from SQL
AB - The last information
- MYSQL web site ? http//www.mysql.com
GNU http//www.gnu.org/licenses/
3You need a commercial license
- Link with any GPL code from the MySQL software
- Distribute a application only work with the MySQL
and ship it with the MySQL software - Distribute copies of MySQL without providing the
source code - Support the further development of the SQL
database
For more information see MySQL Reference
Manual1.4.3.1 Using the MySQL Software Under a
Commercial License
4What is MYSQL
- is a database management system (DBMS)
- a structured collection data
- add and process data in a computer
- is a relational DBMS
- store data in separate tables
- the tables are linked by relations
- is open source
- it is possible for anyone to modify
- using the software without paying anything
5Installing MySQL
- How to get MySQL
- Check the homepage (http//www.mysql.com)
- Operating System Supported
- AIX, Amiga, BSD, DEC, FreeBSD, HP-UX, Linux2.0,
MacOS, NetBSD, OpenBSD, OS2/Warp, SGI Irix6.x,
Solaris 2.5, SunOS 4.x, Caldera(SCO) OpenServer,
Tru65 Unix, Windows 9x Me NT 2000 andXP
6Installation Layout
7Installing MySQL on Windows
- Can running MySQL as a service
- Install MySQL on the NTFS if you want your table
bigger than 4G - TCP/IP protocol support
- Connected to the MySQL
- via ODBC you need MyODBC driver
- MyODBC http//www.mysql.com/downloads/api-myodbc.
html - Via JDBC you need mm driver or Reisin driver
- mmdriver http//www.mysql.com/Downloads/Contrib/
- Reisin http//www.caucho.com/projects/jdbc-mysql/
index.xtp
Download address http//www.mysql.com/downloa
ds/
8Installing the Binaries
- Stop the earlier installation
- C\mysql\bingt mysqladmin -u root shutdown
- Remove the service C\mysql\bingt mysqld-max-nt
--remove - Setup
- Starting the Server for the first time
C\mysql\bin\mysqld-nt --install
Remove the service using --remove
Stop the service using net stop MySQL Start the
service using net start MySQL
9Manager your server
Functions 1. Start the service 2. Stop the
service 3. Edit the My.ini
10Connect to your server
- Client
- Mysql.exe
- Quit
- List all databases
- Show databases
- Using database
- USE test // ????
- Drop table mytable2
- List all tables
- Show tables
- Create database
- Create database ??????
11JDBC Driver for MySQL
- MySQL Connector/J
- Licensed under GPL and commercial license see
MySQLEULA.txt - How to get Connector/J
- http//www.mysql.com
- Installation
- S1 mysql-connector-java-3.0.7-stable-bin.jar ?
c\mysql - S2 setup the JBuilder
- Configure Libraries New a library set the
library path - Project Properties Add the required libraries
12 Connector/J -- JBuilder Setup
2
Give a name for the library
3
Add the library path
1
13 Connector/J -- Project Properties
1
2
Add the Mysql library the your project
14 Test Connector/J now
Create table
import java.sql. public class CreateTable
public static void main(String args)throws
Exception Class.forName("com.mysql.jdbc.
Driver").newInstance()
Connection connDriverManager.getConnection("jdbc
mysql//localhost/test")
Statement sqlStmtconn.createStatement()
String strcreateTable"create table MYTABLE("
"Text char(10)"
")"
sqlStmt.executeUpdate(strcreateTable)
System.out.println("Ok")
Load the Driver
Connect to the DataBase
Execute the SQL command
Example MySQLTest1CreateTable
15Test Connector/J now
import java.sql. public class CreateTable
public static void main(String args)throws
Exception Class.forName("com.mysql.jdbc.
Driver").newInstance()
Connection connDriverManager.getConnection("jdbc
mysql//localhost/test? useUnicodetruecharacter
EncodingMS950") Statement
sqlStmtconn.createStatement() String
strInsert"insert into mytable3
values(\"'????'\")" sqlStmt.executeUpdat
e(strInsert) System.out.println("Ok")
Connect to the DataBase