ITN Wake Tech1 ITN270 Advanced Internet Databases Lecture 14. Introduction to MySQL Administration and the MySQL Data Directory Topics: –Overview of Administrative Duties –MySQL Data Sirectory
ITN Wake Tech2 Overview of Administrative Duties The MySQL Server –mysqld MySQL Clients & Utilities –mysql allows you to send SQL to the server & get results –mysqladmin an administrative program shutting down checking status
ITN Wake Tech3 Overview of Administrative Duties MySQL Clients & Utilities –mysqlcheck –isamchk –myisamchk table analysis table optimization crash recovery –mysqldump backing up databases
ITN Wake Tech4 Overview of Administrative Duties The server’s language –SQL The MySQL data directory –structure where the files located –contents file system
ITN Wake Tech5 Administrative Duties Server startup & shutdown –mysqld start/stop User account maintenance –grant Log file maintenance –it may fill up your system Database backup & copying –mysqldump
ITN Wake Tech6 Administrative Duties Database replication –two servers have the same database –changes made in one propagate to the other Server configuration & tuning –retrieval –updates Multiple servers –each group may have its own server MySQL software updates
ITN Wake Tech7 Security File system security Server security –grant access priviliges
ITN Wake Tech8 Database Repair & Maintenance Crash recovery Preventive maintenance
ITN Wake Tech9 The MySQL Data Directory The MySQL Data Directory Stores –databases –status files –log files
ITN Wake Tech10 Location of the Data Directory Install from a source distribution –/usr/local/mysql/var Install from a binary distribution –/usr/local/mysql/data Install from a RPM file –/var/lib/mysql MS Windows –c:\mysql\data
ITN Wake Tech11 Location of the Data Directory Specification of the location of data directory --datadir = dir_name Ask the server for location –mysqladmin variables –or
ITN Wake Tech12 Structure of the Data Directory Contains all the databases & tables Tree structure –each database has a sub directory –tables in a database - files in the subdirectory Status & Log files
ITN Wake Tech13 How the MySQL Server Provides Access to Data
ITN Wake Tech14 How the MySQL Server Provides Access to Data When the server does not have exclusive control of the data directory –multiple servers on a single data directory –when run the table repair utilities
ITN Wake Tech15 How the MySQL Represents Databases in the File System Each database is a subdirectory under c:\mysql\data Show DATABASES –dir in Windows –ls in unix/Linux CREATE DATABASES db_name –cd DATADIR –mkdir db_name –chmod u=rwx,go-rwx dbname
ITN Wake Tech16 How the MySQL Represents Databases in the File System DROP DATABASE db_name –in UNIX cd DATADIR rm -rf db_name –in Windows cd DATADIR del /s db_name
ITN Wake Tech17 How the Tables are represented ISAM Tables –*.frm - description file for the format –*.ISD - data file for the contents –*.ISM - index information MyISAM Tables –*.frm - format –*.MYD - data –*.MYI - index files
ITN Wake Tech18 How the Tables are represented MERGE Tables –*.frm –*.MRG BDB Tables –*.frm - description –*.db - data & index InnoDB Tables –*.frm –tablespace
ITN Wake Tech19 OS constrains on Database & Table Naming Alphanumeric characters, _, $ 64 characters long other characters can be used by quoting the name in backticks case sensitivity
ITN Wake Tech20 Factors that Affect Maximum Table Size Internal Limits –ISAM:.ISD &.ISM <=4GB –MyISAM:.MYD &.MYI <= 4GB –BDB: 2 TetraBytes –InnoDB: 4Billion x 16KB OS limits: –2GB Data Type of AUTO_INCREMENT
ITN Wake Tech21 Implications of Data Directory Structure for System Performance Multiple files for one table Table opening time increases with the number of tables TIME VS SPACE –Combine tables need more space –More tables need more time Security –More user access same table if combined
ITN Wake Tech22 Status & Log Files Process ID file: –created when mysql starts –removed when shuts down MySQL Log files –General Log file Who is connecting From Where What queries thay are issuing
ITN Wake Tech23 Status & Log Files MySQL Log files –Update Log file queries that update the databases useful when there is a crash –Make sure they will not use up your file system space
ITN Wake Tech24 Relocating Data Directory Contents Relocation Methods –Specify your data directory at start up –Move the data & create a link Assessing the effects of relocation –disk space Relocating the entire data directory
ITN Wake Tech25 Relocating Data Directory Contents Relocating individual databases –shut down the server –copy or move database directory to ite new location –Remove the original database directory –Create a symlink –Restart the server