Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. MySQL Database Administrator Training Guide by L.Ramkumar., M.Sc.(C.S)., D.W.D., M.Com., (Co-Op)., B.G.L., (PhD)
  2. 2. 1. Information about MySQL. 1.1 What is MySQL? 1.2 History of MySQL. 1.3 The Main Features of MySQL. 1.4 MySQL Development Roadmap 1.5 What is new in MySQL 5.0 ? 2 Installing and Upgrading MySQL 2.1 Overview of MySQL Community Server Installation. 2.2 Operating Systems Supported by MySQL Community Server. 2.3 How to Get MySQL ? 2.4 Installation Wizard. 2.5 Starting the MySQL Installation Wizard. 2.5.1 Choosing an Installation Type. 2.5.2 The Custom Installation Dialog. 2.5.3 The Confirmation Dialog. 2.6 Upgrading MySQL with the Installation Wizard. 2.7 MySQL Server Configuration Wizard. 2.7.1 Starting the MySQL Server Configuration Wizard. 2.7.2 Starting the MySQL Server Configuration Wizard on Linux. 2.7.3 Choosing a Configuration Type. 2.7.4 The Server Type Dialog. 2.7.5 The Database Usage Dialog. 2.7.6 The InnoDB Tablespace Dialog. 2.7.7 The Concurrent Connections Dialog. 2.7.8 The Networking and Strict Mode Options Dialog. 2.7.9 The Character Set Dialog.
  3. 3. 2.7.10 The Service Options Dialog. 2.7.11 The Security Option Dialog. 2.7.12 The Confirmation Dialog. 2.8 Selecting a MySQL Server Type. 2.9 Starting MySQL from the Windows. 2.10Installing MySQL from RPM Packages on Linux. 3 Introduction to MySQL Administrator. (Installation). 3.1 Installing Under Windows. 3.2 Installing Under Linux. 3.2.1 Installing the Generic tarball. 3.2.2 RPM Installation. 4 Running MySQL GUI Tools 4.1 Running Under Windows. 4.2 Connection Dialog. 4.3 Server Connections. 4.4 Threads 4.5 User Connections 4.6 User Administration 4.6.1 User Accounts 4.6.2 User Information 4.6.3 Schema Privileges 4.6.4 Global Privileges 4.6.5 Table Column Privileges 5 The MySQL System Tray Monitor 6 Backup 6.1 Backup Project. 6.2 Advanced Options 6.2.1 Backup Execution Method
  4. 4. 6.2.2 Output File Options 7 Restore 7.1 The General Tab 7.2 Restore Content Tab 8 Replication Status 8.1 Configuring Replication Servers 8.2 Using the Replication Status Section 9 Storage Engines 9.1 The MyISAM Storage Engine 9.2 The InnoDB Storage Engine 9.3 The MERGE Storage Engine. 9.4 The MEMORY (HEAP) Storage Engine. 9.5 The EXAMPLE Storage Engine. 9.6 The FEDERATED Storage Engine 9.7 The ARCHIVE Storage Engine 9.8 The CSV Storage Engine 9.9 The BLACKHOLE Storage Engine 10 Optimization
  5. 5. 1. Information about MySQL 1.1 What is MySQL? MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by the MySQL developers. It is a second generation Open Source company that unites Open Source values and methodology with a successful business model. The MySQL Web site ( provides the latest information about MySQL software and MySQL AB. • MySQL is a database management system. A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL Server. Since computers are very good at handling large amounts of data, database management systems play a central role in computing, as standalone utilities, or as parts of other applications. • MySQL is a relational database management system. A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The SQL part of “MySQL” stands for “Structured Query Language.” SQL is the most common standardized language used to access databases and is defined by the ANSI/ISO SQL Standard. The SQL standard has been evolving since 1986 and several versions exist. In this manual, “SQL-92” refers to the standard released in 1992, “SQL:1999” refers to the standard released in 1999, and “SQL:2003” refers to the current version of the standard. We use the phrase “the SQL standard” to mean the current version of the SQL Standard at any time. • MySQL software is Open Source. Open Source means that it is possible for anyone to use and modify the software. Anybody can download the MySQL software from the Internet and use it without paying anything. If you wish, you may study the source code and change it to suit your needs. The MySQL software uses the GPL (GNU General Public License),, to define what you may and may not do with the software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL code into a commercial application, you can buy a commercially licensed version from us. See the MySQL Licensing Overview for more information (
  6. 6. • The MySQL Database Server is very fast, reliable, and easy to use. If that is what you are looking for, you should give it a try. MySQL Server also has a practical set of features developed in close cooperation with our users.. MySQL Server was originally developed to handle large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Although under constant development, MySQL Server today offers a rich and useful set of functions. Its connectivity, speed, and security make MySQL Server highly suited for accessing databases on the Internet. • MySQL Server works in client/server or embedded systems. The MySQL Database Software is a client/server system that consists of a multi- threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and a wide range of application programming interfaces (APIs). We also provide MySQL Server as an embedded multi-threaded library that you can link into your application to get a smaller, faster, easier-to-manage standalone product. • A large amount of contributed MySQL software is available. It is very likely that your favorite application or language supports the MySQL Database Server. The official way to pronounce “MySQL” is “My Ess Que Ell” (not “my sequel”), but we don't mind if you pronounce it as “my sequel” or in some other localized way. 1.2 History of MySQL MySQL is named after co-founder Monty Widenius's daughter, My. The name of the MySQL Dolphin (our logo) is “Sakila,” which was chosen by the founders of MySQL AB from a huge list of names suggested by users in our “Name the Dolphin” contest. The winning name was submitted by Ambrose Twebaze, an Open Source software developer from Swaziland, Africa. According to Ambrose, the feminine name Sakila has its roots in SiSwati, the local language of Swaziland. Sakila is also the name of a town in Arusha, Tanzania, near Ambrose's country of origin, Uganda.
  7. 7. 1.3 The Main Features of MySQL Internals and Portability: • Written in C and C++. • Tested with a broad range of different compilers. • Works on many different platforms • Uses GNU Automake, Autoconf, and Libtool for portability. • The MySQL Server design is multi-layered with independent modules. • Fully multi-threaded using kernel threads. It can easily use multiple CPUs if they are available. • Provides transactional and non-transactional storage engines. • Uses very fast B-tree disk tables (MyISAM) with index compression. • Relatively easy to add other storage engines. This is useful if you want to provide an SQL interface for an in-house database. • A very fast thread-based memory allocation system. • Very fast joins using an optimized one-sweep multi-join. • In-memory hash tables, which are used as temporary tables. • SQL functions are implemented using a highly optimized class library and should be as fast as possible. Usually there is no memory allocation at all after query initialization. • The MySQL code is tested with Purify (a commercial memory leakage detector) as well as with Valgrind, a GPL tool ( • The server is available as a separate program for use in a client/server networked environment. It is also available as a library that can be embedded (linked) into standalone applications. Such applications can be used in isolation or in environments where no network is available. Data Types: • Many data types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long, FLOAT, DOUBLE, CHAR, VARCHAR, TEXT, BLOB, DATE, TIME, DATETIME, TIMESTAMP, YEAR, SET, ENUM, and OpenGIS spatial types. • Fixed-length and variable-length records. Statements and Functions: • Full operator and function support in the SELECT list and WHERE clause of queries. For example: mysql> SELECT CONCAT(first_name, ' ', last_name) -> FROM citizen -> WHERE income/dependents > 10000 AND age > 30;
  8. 8. • Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions (COUNT(), COUNT(DISTINCT ...), AVG(), STD(), SUM(), MAX(), MIN(), and GROUP_CONCAT()). • Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both standard SQL and ODBC syntax. • Support for aliases on tables and columns as required by standard SQL. • DELETE, INSERT, REPLACE, and UPDATE return the number of rows that were changed (affected). It is possible to return the number of rows matched instead by setting a flag when connecting to the server. • The MySQL-specific SHOW statement can be used to retrieve information about databases, storage engines, tables, and indexes. MySQL 5.0 adds support for the INFORMATION_SCHEMA database, implemented according to standard SQL. • The EXPLAIN statement can be used to determine how the optimizer resolves a query. • Function names do not clash with table or column names. For example, ABS is a valid column name. The only restriction is that for a function call, no spaces are allowed between the function name and the “(” that follows it. • You can refer to tables from different databases in the same statement. Security: • A privilege and password system that is very flexible and secure, and that allows host-based verification. • Passwords are secure because all password traffic is encrypted when you connect to a server. Scalability and Limits: • Handles large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 60,000 tables and about 5,000,000,000 rows. • Up to 64 indexes per table are allowed (32 before MySQL 4.1.2). Each index may consist of 1 to 16 columns or parts of columns. The maximum index width is 1000 bytes (767 for InnoDB); before MySQL 4.1.2, the limit is 500 bytes. An index may use a prefix of a column for CHAR, VARCHAR, BLOB, or TEXT column types. Connectivity: • Clients can connect to MySQL Server using several protocols: o Clients can connect using TCP/IP sockets on any platform. o On Windows systems in the NT family (NT, 2000, XP, 2003, or Vista), clients can connect using named pipes if the server is started with the --enable-named-pipe option. In MySQL 4.1 and higher, Windows servers also support shared-memory connections if started with the
  9. 9. --shared-memory option. Clients can connect through shared memory by using the --protocol=memory option. o On Unix systems, clients can connect using Unix domain socket files. • MySQL client programs can be written in many languages. A client library written in C is available for clients written in C or C++, or for any language that provides C bindings. • APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, allowing MySQL clients to be written in many languages. • The Connector/ODBC (MyODBC) interface provides MySQL support for client programs that use ODBC (Open Database Connectivity) connections. For example, you can use MS Access to connect to your MySQL server. Clients can be run on Windows or Unix. MyODBC source is available. All ODBC 2.5 functions are supported, as are many others. • The Connector/J interface provides MySQL support for Java client programs that use JDBC connections. Clients can be run on Windows or Unix. Connector/J source is available. • MySQL Connector/NET enables developers to easily create .NET applications that require secure, high-performance data connectivity with MySQL. It implements the required ADO.NET interfaces and integrates into ADO.NET aware tools. Developers can build applications using their choice of .NET languages. MySQL Connector/NET is a fully managed ADO.NET driver written in 100% pure C#. Localization: • The server can provide error messages to clients in many languages. • Full support for several different character sets, including latin1 (cp1252), german, big5, ujis, and more. For example, the Scandinavian characters “å”, “ä” and “ö” are allowed in table and column names. Unicode support is available as of MySQL 4.1. • All data is saved in the chosen character set. • Sorting and comparisons are done according to the chosen character set and collation (using latin1 and Swedish collation by default). It is possible to change this when the MySQL server is started. To see an example of very advanced sorting, look at the Czech sorting code. MySQL Server supports many different character sets that can be specified at compile time and runtime. • As of MySQL 4.1, the server time zone can be changed dynamically, and individual clients can specify their own time zone Clients and Tools: • MySQL AB provides several client and utility programs. These include both command-line programs such as mysqldump and mysqladmin, and graphical programs such as MySQL Administrator and MySQL Query Browser. • MySQL Server has built-in support for SQL statements to check, optimize, and repair tables. These statements are available from the command line through the
  10. 10. mysqlcheck client. MySQL also includes myisamchk, a very fast command- line utility for performing these operations on MyISAM tables. • MySQL programs can be invoked with the --help or -? option to obtain online assistance. 1.4 MySQL Development Roadmap The current production release series is MySQL 5.0, which was declared stable for production use as of MySQL 5.0.15, released in October 2005. The previous production release series was MySQL 4.1, which was declared stable for production use as of MySQL 4.1.7, released in October 2004. “Production status” means that future 5.0 and 4.1 development is limited only to bugfixes. For the older MySQL 4.0 and 3.23 series, only critical bugfixes are made. Active MySQL development currently is taking place in the MySQL 5.0 and 5.1 release series, and new features are being added only to the latter The most requested features and the versions in which they were implemented or are scheduled for implementation are summarized in the following table: Feature MySQL Series Unions 4.0 Subqueries 4.1 R-trees 4.1 (for the MyISAM storage engine) Stored procedures 5.0 Views 5.0 Cursors 5.0 XA transactions 5.0 Triggers 5.0 and 5.1 Event scheduler 5.1 Partitioning 5.1 Pluggable storage engine API 5.1 Plugin API 5.1 Row-based replication 5.1 Server log tables 5.1 Foreign keys 6.x (implemented in 3.23 for InnoDB)
  11. 11. 1.5 What's New in MySQL 5.0 The following features are implemented in MySQL 5.0. • BIT Data Type: Can be used to store numbers in binary notation • Cursors: Elementary support for server-side cursors • Information Schema: The introduction of the INFORMATION_SCHEMA database in MySQL 5.0 provided a standards-compliant means for accessing the MySQL Server's metadata; that is, data about the databases (schemas) on the server and the objects which they contain. • Instance Manager: Can be used to start and stop the MySQL Server, even from a remote host. • Precision Math: MySQL 5.0 introduced stricter criteria for acceptance or rejection of data, and implemented a new library for fixed-point arithmetic. These contributed to a much higher degree of accuracy for mathematical operations and greater control over invalid values. • Storage Engines: Storage engines added in MySQL 5.0 include ARCHIVE and FEDERATED. . • Stored Routines: Support for named stored procedures and stored functions was implemented in MySQL 5.0. • Strict Mode and Standard Error Handling: MySQL 5.0 added a strict mode where by it follows standard SQL in a number of ways in which it did not previously. • Triggers: MySQL 5.0 added limited support for triggers. . • VARCHAR Data Type: The effective maximum length of a VARCHAR column was increased to 65,535 bytes, and stripping of trailing whitespace was eliminated. (The actual maximum length of a VARCHAR is determined by the maximum row size and the character set you use. The maximum effective column length is subject to a row size of 65,535 bytes, which is shared among all columns.) • Views: MySQL 5.0 added support for named, updatable views. • XA Transactions • Performance enhancements: A number of improvements were made in MySQL 5.0 to improve the speed of certain types of queries and in the handling of certain types. These include: o MySQL 5.0 introduces a new “greedy” optimizer which can greatly reduce the time required to arrive at a query execution plan. This is particularly noticeable where several tables are to be joined and no good join keys can otherwise be found. Without the greedy optimizer, the complexity of the search for an execution plan is calculated as N!, where N is the number of tables to be joined. The greedy optimizer reduces this to N!/(D-1)!, where D is the depth of the search. Although the greedy optimizer does not guarantee the best possible of all execution plans (this is currently being worked on), it can reduce the time spent arriving at an execution plan for a join involving a great many tables — 30, 40, or more — by a factor of as much as 1,000. This should eliminate most if not all
  12. 12. situations where users thought that the optimizer had hung when trying to perform joins across many tables. o Use of the Index Merge method to obtain better optimization of AND and OR relations over different keys. (Previously, these were optimized only where both relations in the WHERE clause involved the same key.) This also applies to other one-to-one comparison operators (>, <, and so on), including = and the IN operator. This means that MySQL can use multiple indexes in retrieving results for conditions such as WHERE key1 > 4 OR key2 < 7 and even combinations of conditions such as WHERE (key1 > 4 OR key2 < 7) AND (key3 >= 10 OR key4 = 1). o A new equality detector finds and optimizes “hidden” equalities in joins. For example, a WHERE clause such as t1.c1=t2.c2 AND t2.c2=t3.c3 AND t1.c1 < 5 implies these other conditions t1.c1=t3.c3 AND t2.c2 < 5 AND t3.c3 < 5 These optimizations can be applied with any combination of AND and OR operators. o Optimization of NOT IN and NOT BETWEEN relations, reducing or eliminating table scans for queries making use of them by mean of range analysis. The performance of MySQL with regard to these relations now matches its performance with regard to IN and BETWEEN. o The VARCHAR data type as implemented in MySQL 5.0 is more efficient than in previous versions, due to the elimination of the old (and nonstandard) removal of trailing spaces during retrieval. o The addition of a true BIT column type; this type is much more efficient for storage and retrieval of Boolean values than the workarounds required in MySQL in versions previous to 5.0. o Performance Improvements in the InnoDB Storage Engine:  New compact storage format which can save up to 20% of the disk space required in previous MySQL/InnoDB versions.  Faster recovery from a failed or aborted ALTER TABLE.  Faster implementation of TRUNCATE. o Performance Improvements in the NDBCluster Storage Engine:  Faster handling of queries that use IN and BETWEEN.  Condition pushdown: In cases involving the comparison of an unindexed column with a constant, this condition is “pushed down” to the cluster where it is evaluated in all partitions simultaneously, eliminating the need to send non-matching records over the network. This can make such queries 10 to 100 times faster than in MySQL 4.1 Cluster.
  13. 13. 2.0 Installing and Upgrading MySQL 2.1 Overview of MySQL Community Server Installation 1. Determine whether MySQL runs and is supported on your platform. Not all platforms are equally suitable for running MySQL, and not all platforms on which MySQL is known to run are officially supported by MySQL AB. 2. Choose which distribution to install. Several versions of MySQL are available, and most are available in multiple distribution formats. You can choose from prepackaged distributions containing binary (precompiled) programs or source code. When in doubt, use a binary distribution. 3. Download the distribution that you want to install. . 4. Install the distribution. 5. Perform any necessary post-installation setup. After installing MySQL, read Post-Installation Setup and Testing which contains important information about making sure the MySQL server is working properly. It also describes how to secure the initial MySQL user accounts, which have no passwords until you assign passwords. The information in this section applies whether you install MySQL using a binary or source distribution. 6. Perform setup for running benchmarks (optional). If you want to use the MySQL benchmark scripts, Perl support for MySQL must be available 2.2 Operating Systems Supported by MySQL Community Server. MySQL has been reported to compile successfully on the following combinations of operating system and thread package. • AIX 4.x and 5.x with native threads. • FreeBSD 5.x and up with native threads. • HP-UX 11.x with native threads. • Linux. MySQL builds on all fairly recent Linux distributions with glibc 2.3. • Mac OS X. • NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha. • Novell NetWare 6.0 and 6.5. • OpenBSD 2.5 and with native threads. OpenBSD earlier than 2.5 with the MIT- pthreads package. . • SCO Openserver 6.0.x • SCO UnixWare 7.1.x. • SGI Irix 6.x with native threads. • Solaris 2.5 and above with native threads on SPARC and x86. • Tru64 Unix. • Windows 2000, XP, and Windows Server 2003, as well as 32-bit Windows Vista.
  14. 14. 2.3 How to Get MySQL Check downloads page at for information about the current version of MySQL and for downloading instructions. For a complete up-to-date list of MySQL download mirror sites, see Installation Layouts This section describes the default layout of the directories created by installing binary or source distributions provided by MySQL AB. For MySQL 5.0 on Windows, the default installation directory is C:Program FilesMySQLMySQL Server 5.0. (Some Windows users prefer to install in C:mysql, the directory that formerly was used as the default. However, the layout of the subdirectories remains the same.) The installation directory has the following subdirectories: Directory Contents bin Client programs and the mysqld server data Log files, databases Docs Manual in CHM format examples Example programs and scripts include Include (header) files lib Libraries scripts Utility scripts share Error message files Installations created from MySQL AB's Linux RPM distributions result in files under the following system directories: Directory Contents /usr/bin Client programs and scripts /usr/sbin The mysqld server /var/lib/mysql Log files, databases /usr/share/info Manual in Info format /usr/share/man Unix man pages /usr/include/mysql Include (header) files /usr/lib/mysql Libraries /usr/share/mysql Error message and character set files
  15. 15. /usr/share/sql-bench Benchmarks On Unix, a tar file binary distribution is installed by unpacking it at the installation location you choose (typically /usr/local/mysql) and creates the following directories in that location: Directory Contents bin Client programs and the mysqld server data Log files, databases docs Manual in Info format man Unix manual pages include Include (header) files lib Libraries scripts mysql_install_db share/mysql Error message files sql-bench Benchmarks 2.4 Installation Wizard MySQL Installation Wizard is an installer for the MySQL server that uses the latest installer technologies for Microsoft Windows. The MySQL Installation Wizard, in combination with the MySQL Configuration Wizard, allows a user to install and configure a MySQL server that is ready for use immediately after installation. The MySQL Installation Wizard is the standard installer for all MySQL server distributions, version 4.1.5 and higher. Users of previous versions of MySQL need to shut down and remove their existing MySQL installations manually before installing MySQL with the MySQL Installation Wizard For MySQL 5.0, there are three installation packages to choose from when installing MySQL on Windows: • The Essentials package. This package has a filename similar to mysql- essential-5.0.60-win32.msi and contains the minimum set of files needed to install MySQL on Windows, including the Configuration Wizard. This
  16. 16. package does not include optional components such as the embedded server and benchmark suite. • The Complete package. This package has a filename similar to and contains all files needed for a complete Windows installation, including the Configuration Wizard. This package includes optional components such as the embedded server and benchmark suite. • The no-install archive. This package has a filename similar to mysql- and contains all the files found in the Complete install package, with the exception of the Configuration Wizard. This package does not include an automated installer, and must be manually installed and configured. 2.5 Starting the MySQL Installation Wizard The process for starting the wizard depends on the contents of the installation package you download. If there is a setup.exe file present, double-click it to start the installation process. If there is an .msi file present, double-click it to start the installation process 2.5.1 Choosing an Installation Type There are three installation types available: Typical, Complete, and Custom
  17. 17. The Typical installation type installs the MySQL server, the mysql command-line client, and the command-line utilities. The command-line clients and utilities include mysqldump, myisamchk, and several other tools to help you manage the MySQL server. The Complete installation type installs all components included in the installation package. The full installation package includes components such as the embedded server library, the benchmark suite, support scripts, and documentation. The Custom installation type gives you complete control over which packages you wish to install and the installation path that is used. If you choose the Typical or Complete installation types and click the Next button, you advance to the confirmation screen to verify your choices and begin the installation. If you choose the Custom installation type and click the Next button, you advance to the custom installation dialog 2.5.2 The Custom Installation Dialog. If you wish to change the installation path or the specific components that are installed by the MySQL Installation Wizard, choose the Custom installation type
  18. 18. A tree view on the left side of the custom install dialog lists all available components. Components that are not installed have a red X icon; components that are installed have a gray icon. To change whether a component is installed, click on that component's icon and choose a new option from the drop-down list that appears. You can change the default installation path by clicking the Change... button to the right of the displayed installation path. After choosing your installation components and installation path, click the Next button to advance to the confirmation dialog. 2.5.3 The Confirmation Dialog Once you choose an installation type and optionally choose your installation components, you advance to the confirmation dialog. Your installation type and installation path are displayed for you to review To install MySQL if you are satisfied with your settings, click the Install button. To change your settings, click the Back button. To exit the MySQL Installation Wizard without installing MySQL, click the Cancel button.
  19. 19. After installation is complete, you have the option of registering with the MySQL web site. 2.6 Upgrading MySQL with the Installation Wizard The MySQL Installation Wizard can perform server upgrades automatically using the upgrade capabilities of MSI. That means you do not need to remove a previous installation manually before installing a new release. The installer automatically shuts down and removes the previous MySQL service before installing the new version. Automatic upgrades are available only when upgrading between installations that have the same major and minor version numbers. For example, you can upgrade automatically from MySQL 4.1.5 to MySQL 4.1.6, but not from MySQL 4.1 to MySQL 5.0. 2.7 MySQL Server Configuration Wizard
  20. 20. The MySQL Server Configuration Wizard helps automate the process of configuring your server. It creates a custom MySQL configuration file (my.ini or my.cnf) by asking you a series of questions and then applying your responses to a template to generate the configuration file that is tuned to your installation. The MySQL Server Configuration Wizard is included with the MySQL 5.0 server. For Community Server users, the MySQL Server Configuration Wizard is available only for Windows. For Enterprise Server users, the MySQL Server Configuration Wizard is included as part of the standard Enterprise Installer. 2.7.1 Starting the MySQL Server Configuration Wizard The MySQL Server Configuration Wizard is normally started as part of the installation process. You should only need to run the MySQL Server Configuration Wizard again when you need to change the configuration parameters of your server. If you chose not to open a port prior to installing MySQL on Windows Vista, you can choose to use the MySQL Server Configuration Wizard after installation. However, you must open a port in the Windows Firewall. Rather than opening a port, you also have the option of adding MySQL as a program that bypasses the Windows Firewall. One or the other option is sufficient — you need not do both. Additionally, when running the MySQL Server Configuration Wizard on Windows Vista ensure that you are logged in as a user with administrative rights.
  21. 21. You can launch the MySQL Configuration Wizard by clicking the MySQL Server Instance Config Wizard entry in the MySQL section of the Windows Start menu. Alternatively, you can navigate to the bin directory of your MySQL installation and launch the MySQLInstanceConfig.exe file directly. The MySQL Server Configuration Wizard places the my.ini file in the installation directory for the MySQL server. This helps associate configuration files with particular server instances. To ensure that the MySQL server knows where to look for the my.ini file, an argument similar to this is passed to the MySQL server as part of the service installation: --defaults-file="C:Program FilesMySQLMySQL Server 5.0my.ini" Here, C:Program FilesMySQLMySQL Server 5.0 is replaced with the installation path to the MySQL Server. The --defaults-file option instructs the MySQL server to read the specified file for configuration options when it starts. Apart from making changes to the my.ini file by running the MySQL Server Configuration Wizard again, you can modify it by opening it with a text editor and making any necessary changes. You can also modify the server configuration with the MySQL Administrator utility. MySQL clients and utilities such as the mysql and mysqldump command-line clients are not able to locate the my.ini file located in the server installation directory. To configure the client and utility applications, create a new my.ini file in the Windows installation directory (for example, C:WINDOWS). Under Windows Server 2003, Windows Server 2000 and Windows XP, MySQL Server Configuration Wizard will configure MySQL to work as a Windows service. To start and stop MySQL you use the Services application that is supplied as part of the Windows Administrator Tools. 2.7.2 Starting the MySQL Server Configuration Wizard on Linux To start the MySQL Configuration Wizard on Linux, you must run the mysqlsetup command. You must be running an X Windows System server for the MySQL Server Configuration Wizard. To display the MySQL Server Configuration Wizard interface on a different machine, set the value of the DISPLAY variable on the command line: shell> DISPLAY=remote:0.0 mysqlsetup
  22. 22. The MySQL Server Configuration Wizard places the my.cnf file in the /etc directory. This configuration file is automatically used when mysqld is started. The standard MySQL server initialization script, typically located within /etc/init.d/mysql, will also use this file automatically. Apart from making changes to the my.ini file by running the MySQL Server Configuration Wizard again, you can modify it by opening it with a text editor and making any necessary changes. You can also modify the server configuration with the MySQL Administrator utility. 2.7.3 Choosing a Configuration Type When you start the MySQL Server Configuration Wizard for a new MySQL installation, or choose the Re-configure Instance option for an existing installation, you advance to the Configuration Type dialog. There are two configuration types available: Detailed Configuration and Standard Configuration. The Standard Configuration option is intended for new users who want to get started with MySQL quickly without having to make many decisions about server configuration. The Detailed Configuration option is intended for advanced users who want more fine-grained control over server configuration.
  23. 23. If you are new to MySQL and need a server configured as a single-user developer machine, the Standard Configuration should suit your needs. Choosing the Standard Configuration option causes the MySQL Configuration Wizard to set all configuration options automatically with the exception of Service Options and Security Options. The Standard Configuration sets options that may be incompatible with systems where there are existing MySQL installations. If you have an existing MySQL installation on your system in addition to the installation you wish to configure, the Detailed Configuration option is recommended 2.7.4 The Server Type Dialog There are three different server types available to choose from. The server type that you choose affects the decisions that the MySQL Server Configuration Wizard makes with regard to memory, disk, and processor usage. • Developer Machine: Choose this option for a typical desktop workstation where MySQL is intended only for personal use. It is assumed that many other desktop applications are running. The MySQL server is configured to use minimal system resources. • Server Machine: Choose this option for a server machine where the MySQL server is running alongside other server applications such as FTP, email, and Web
  24. 24. servers. The MySQL server is configured to use a moderate portion of the system resources. • Dedicated MySQL Server Machine: Choose this option for a server machine that is intended to run only the MySQL server. It is assumed that no other applications are running. The MySQL server is configured to use all available system resources. 2.7.5 The Database Usage Dialog The Database Usage dialog allows you to indicate the storage engines that you expect to use when creating MySQL tables. The option you choose determines whether the InnoDB storage engine is available and what percentage of the server resources are available to InnoDB. • Multifunctional Database: This option enables both the InnoDB and MyISAM storage engines and divides resources evenly between the two. This option is recommended for users who use both storage engines on a regular basis. • Transactional Database Only: This option enables both the InnoDB and MyISAM storage engines, but dedicates most server resources to the InnoDB storage engine. This option is recommended for users who use InnoDB almost exclusively and make only minimal use of MyISAM. • Non-Transactional Database Only: This option disables the InnoDB storage engine completely and dedicates all server resources to the MyISAM storage engine. This option is recommended for users who do not use InnoDB.
  25. 25. The Configuration Wizard uses a template to generate the server configuration file. The Database Usage dialog sets one of the following option strings: Multifunctional Database: MIXED Transactional Database Only: INNODB Non-Transactional Database Only: MYISAM When these options are processed through the default template (my-template.ini) the result is: Multifunctional Database: default-storage-engine=InnoDB _myisam_pct=50 Transactional Database Only: default-storage-engine=InnoDB _myisam_pct=5 Non-Transactional Database Only: default-storage-engine=MyISAM _myisam_pct=100 skip-innodb The _myisam_pct value is used to calculate the percentage of resources dedicated to MyISAM. The remaining resources are allocated to InnoDB. 2.7.6 The InnoDB Tablespace Dialog Some users may want to locate the InnoDB tablespace files in a different location than the MySQL server data directory. Placing the tablespace files in a separate location can be desirable if your system has a higher capacity or higher performance storage device available, such as a RAID storage system.
  26. 26. To change the default location for the InnoDB tablespace files, choose a new drive from the drop-down list of drive letters and choose a new path from the drop-down list of paths. To create a custom path, click the ... button. If you are modifying the configuration of an existing server, you must click the Modify button before you change the path. In this situation you must move the existing tablespace files to the new location manually before starting the server 2.7.7 The Concurrent Connections Dialog To prevent the server from running out of resources, it is important to limit the number of concurrent connections to the MySQL server that can be established. The Concurrent Connections dialog allows you to choose the expected usage of your server, and sets the limit for concurrent connections accordingly. It is also possible to set the concurrent connection limit manually.
  27. 27. • Decision Support (DSS)/OLAP: Choose this option if your server does not require a large number of concurrent connections. The maximum number of connections is set at 100, with an average of 20 concurrent connections assumed. • Online Transaction Processing (OLTP): Choose this option if your server requires a large number of concurrent connections. The maximum number of connections is set at 500. • Manual Setting: Choose this option to set the maximum number of concurrent connections to the server manually. Choose the number of concurrent connections from the drop-down box provided, or enter the maximum number of connections into the drop-down box if the number you desire is not listed. 2.7.8 The Networking and Strict Mode Options Dialog Use the Networking Options dialog to enable or disable TCP/IP networking and to configure the port number that is used to connect to the MySQL server
  28. 28. TCP/IP networking is enabled by default. To disable TCP/IP networking, uncheck the box next to the Enable TCP/IP Networking option. Port 3306 is used by default. To change the port used to access MySQL, choose a new port number from the drop-down box or type a new port number directly into the drop- down box. If the port number you choose is in use, you are prompted to confirm your choice of port number. Set the Server SQL Mode to either enable or disable strict mode. Enabling strict mode (default) makes MySQL behave more like other database management systems. If you run applications that rely on MySQL's old “forgiving” behavior, make sure to either adapt those applications or to disable strict mode 2.7.9 The Character Set Dialog The MySQL server supports multiple character sets and it is possible to set a default server character set that is applied to all tables, columns, and databases unless overridden. Use the Character Set dialog to change the default character set of the MySQL server.
  29. 29. • Standard Character Set: Choose this option if you want to use latin1 as the default server character set. latin1 is used for English and many Western European languages. • Best Support For Multilingualism: Choose this option if you want to use utf8 as the default server character set. This is a Unicode character set that can store characters from many different languages. • Manual Selected Default Character Set / Collation: Choose this option if you want to pick the server's default character set manually. Choose the desired character set from the provided drop-down list. 2.7.10 The Service Options Dialog On Windows platforms, the MySQL server can be installed as a Windows service. When installed this way, the MySQL server can be started automatically during system startup, and even restarted automatically by Windows in the event of a service failure. The MySQL Server Configuration Wizard installs the MySQL server as a service by default, using the service name MySQL. If you do not wish to install the service, uncheck the box next to the Install As Windows Service option. You can change the service name
  30. 30. by picking a new service name from the drop-down box provided or by entering a new service name into the drop-down box. To install the MySQL server as a service but not have it started automatically at startup, uncheck the box next to the Launch the MySQL Server Automatically option. 2.7.11 The Security Options Dialog It is strongly recommended that you set a root password for your MySQL server, and the MySQL Server Configuration Wizard requires by default that you do so. If you do not wish to set a root password, uncheck the box next to the Modify Security Settings option To set the root password, enter the desired password into both the New root password and Confirm boxes. If you are reconfiguring an existing server, you need to enter the existing root password into the Current root password box. To prevent root logins from across the network, check the box next to the Root may only connect from localhost option. This increases the security of your root account. To create an anonymous user account, check the box next to the Create An Anonymous Account option. Creating an anonymous account can decrease server security and cause login and permission difficulties. For this reason, it is not recommended.
  31. 31. 2.7.12 The Confirmation Dialog The final dialog in the MySQL Server Configuration Wizard is the Confirmation Dialog . To start the configuration process, click the Execute button. To return to a previous dialog, click the Back button. To exit the MySQL Server Configuration Wizard without configuring the server, click the Cancel button. After you click the Execute button, the MySQL Server Configuration Wizard performs a series of tasks and displays the progress onscreen as the tasks are performed. The MySQL Server Configuration Wizard first determines configuration file options based on your choices using a template prepared by MySQL AB developers and engineers. This template is named my-template.ini and is located in your server installation directory. The MySQL Configuration Wizard then writes these options to the corresponding configuration file. If you chose to create a service for the MySQL server, the MySQL Server Configuration Wizard creates and starts the service. If you are reconfiguring an existing service, the MySQL Server Configuration Wizard restarts the service to apply your configuration changes.
  32. 32. If you chose to set a root password, the MySQL Configuration Wizard connects to the server, sets your new root password, and applies any other security settings you may have selected. After the MySQL Server Configuration Wizard has completed its tasks, it displays a summary. Click the Finish button to exit the MySQL Server Configuration Wizard 2.8 Selecting a MySQL Server Type The following table shows the available servers for Windows in MySQL 5.0. Binary Description mysqld-nt Optimized binary with named-pipe support mysqld Optimized binary without named-pipe support mysqld- Like mysqld-nt, but compiled with full debugging and automatic debug memory allocation checking All of the preceding binaries are optimized for modern Intel processors, but should work on any Intel i386-class or higher processor. Each of the servers in a distribution support the same set of storage engines. The SHOW ENGINES statement displays which engines a given server supports. All Windows MySQL 5.0 servers have support for symbolic linking of database directories. MySQL supports TCP/IP on all Windows platforms. MySQL servers on Windows support named pipes as indicated in the following list. However, the default is to use TCP/IP regardless of platform. (Named pipes are slower than TCP/IP in many Windows configurations.) Use of named pipes is subject to these conditions: • Named pipes are enabled only if you start the server with the --enable- named-pipe option. It is necessary to use this option explicitly because some users have experienced problems with shutting down the MySQL server when named pipes were used. • Named-pipe connections are allowed only by the mysqld-nt and mysqld- debug servers. 2.9 Starting MySQL from the Windows
  33. 33. 2.10 Installing MySQL from RPM Packages on Linux The recommended way to install MySQL on RPM-based Linux distributions is by using the RPM packages. The RPMs provided by MySQL AB to the community should work on all versions of Linux that support RPM packages and use glibc 2.3. MySQL AB also provides RPMs with binaries that are statically linked to a patched version of glibc 2.2, but only for the x86 (32-bit) architecture For non-RPM Linux distributions, you can install MySQL using a .tar.gz package. MySQL AB does provide some platform-specific RPMs; the difference between a platform-specific RPM and a generic RPM is that a platform-specific RPM is built on the targeted platform and is linked dynamically whereas a generic RPM is linked statically with LinuxThreads. Note RPM distributions of MySQL often are provided by other vendors. Be aware that they may differ in features and capabilities from those built by MySQL AB, and that the instructions in this manual do not necessarily apply to installing them. The vendor's instructions should be consulted instead.
  34. 34. In most cases, you need to install only the MySQL-server and MySQL-client packages to get a functional MySQL installation. The other packages are not required for a standard installation. For upgrades, if your installation was originally produced by installing multiple RPM packages, it is best to upgrade all the packages, not just some. For example, if you previously installed the server and client RPMs, do not upgrade just the server RPM. If you get a dependency failure when trying to install MySQL packages (for example, error: removing these packages would break dependencies: is needed by ...), you should also install the MySQL-shared-compat package, which includes both the shared libraries for backward compatibility ( for MySQL 4.0 and for MySQL 3.23). Some Linux distributions still ship with MySQL 3.23 and they usually link applications dynamically to save disk space. If these shared libraries are in a separate package (for example, MySQL-shared), it is sufficient to simply leave this package installed and just upgrade the MySQL server and client packages (which are statically linked and do not depend on the shared libraries). For distributions that include the shared libraries in the same package as the MySQL server (for example, Red Hat Linux), you could either install our 3.23 MySQL-shared RPM, or use the MySQL-shared-compat package instead. (Do not install both.) The RPM packages shown in the following list are available. The names shown here use a suffix of .glibc23.i386.rpm, but particular packages can have different suffixes, as described later. Packages that have community in the names are Community Server builds, available from MySQL 5.0.27 on. • MySQL-server-VERSION.glibc23.i386.rpm, MySQL-server- community-VERSION.glibc23.i386.rpm The MySQL server. You need this unless you only want to connect to a MySQL server running on another machine. • MySQL-client-VERSION.glibc23.i386.rpm, MySQL-client- community-VERSION.glibc23.i386.rpm The standard MySQL client programs. You probably always want to install this package. • MySQL-bench-VERSION.glibc23.i386.rpm Tests and benchmarks. Requires Perl and the DBI and DBD::mysql modules.
  35. 35. • MySQL-devel-VERSION.glibc23.i386.rpm, MySQL-devel- community-VERSION.glibc23.i386.rpm The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules. • MySQL-debuginfo-VERSION.glibc23.i386.rpm, MySQL-community- debuginfo-VERSION.glibc23.i386.rpm This package contains debugging information. debuginfo RPMs are never needed to use MySQL software; this is true both for the server and for client programs. However, they contain additional information that might be needed by a debugger to analyze a crash. • MySQL-shared-VERSION.glibc23.i386.rpm, MySQL-shared- community-VERSION.glibc23.i386.rpm This package contains the shared libraries (*) that certain languages and applications need to dynamically load and use MySQL. It contains single-threaded and thread-safe libraries. If you install this package, do not install the MySQL-shared-compat package. • MySQL-shared-compat-VERSION.glibc23.i386.rpm This package includes the shared libraries for MySQL 3.23, 4.0, 4.1, and 5.0. It contains single-threaded and thread-safe libraries. Install this package instead of MySQL-shared if you have applications installed that are dynamically linked against older versions of MySQL but you want to upgrade to the current version without breaking the library dependencies. • MySQL-clustermanagement- communityVERSION.glibc23.i386.rpm, MySQL-clusterstorage- communityVERSION.glibc23.i386.rpm, MySQL-clustertools- communityVERSION.glibc23.i386.rpm, MySQL-clusterextra- communityVERSION.glibc23.i386.rpm Packages that contain additional files for MySQL Cluster installations. These are platform-specific RPMs, in contrast to the platform-independent ndb-xxx RPMs. Note The MySQL-clustertools RPM requires a working installation of perl and the DBI and HTML::Template packages
  36. 36. • MySQL-ndb-management-VERSION.glibc23.i386.rpm, MySQL-ndb- storage-VERSION.glibc23.i386.rpm, MySQL-ndb-tools- VERSION.glibc23.i386.rpm, MySQL-ndb-extra- VERSION.glibc23.i386.rpm Packages that contain additional files for MySQL Cluster installations. These are platform-independent RPMs, in contrast to the platform-specific clusterxxx- community RPMs. • MySQL-test-community-VERSION.glibc23.i386.rpm This package includes the MySQL test suite. • MySQL-VERSION.src.rpm This contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, Alpha or SPARC). The suffix of RPM package names (following the VERSION value) has the following syntax: [.PLATFORM].CPU.rpm The PLATFORM and CPU values indicate the type of system for which the package is built. PLATFORM, if present, indicates the platform, and CPU indicates the processor type or family. If the PLATFORM value is missing (for example, MySQL-server- VERSION.i386.rpm), the package is statically linked against a version of glibc 2.2 that has been patched to handle larger numbers of threads with larger stack sizes than the stock library. If PLATFORM is present, the package is dynamically linked against glibc 2.3 and the PLATFORM value indicates whether the package is platform independent or intended for a specific platform: glibc23 Platform independent, should run on any Linux distribution that supports glibc 2.3 rhel3, rhel4 Red Hat Enterprise Linux 3 or 4 sles9, SuSE Linux Enterprise Server 9 or 10 sles10 The CPU value indicates the processor type or family for which the package is built:
  37. 37. i386 x86 processor, 386 and up i586 x86 processor, Pentium and up x86_64 64-bit x86 processor ia64 Itanium (IA-64) processor To see all files in an RPM package (for example, a MySQL-server RPM), run a command like this: shell> rpm -qpl MySQL-server-VERSION.glibc23.i386.rpm To perform a standard minimal installation, install the server and client RPMs: shell> rpm -i MySQL-server-VERSION.glibc23.i386.rpm shell> rpm -i MySQL-client-VERSION.glibc23.i386.rpm To install only the client programs, install just the client RPM: shell> rpm -i MySQL-client-VERSION.glibc23.i386.rpm RPM provides a feature to verify the integrity and authenticity of packages before installing them. If you would like to learn more about this feature. The server RPM places data under the /var/lib/mysql directory. The RPM also creates a login account for a user named mysql (if one does not exist) to use for running the MySQL server, and creates the appropriate entries in /etc/init.d/ to start the server automatically at boot time. (This means that if you have performed a previous installation and have made changes to its startup script, you may want to make a copy of the script so that you don't lose it when you install a newer RPM.) If you want to install the MySQL RPM on older Linux distributions that do not support initialization scripts in /etc/init.d (directly or via a symlink), you should create a symbolic link that points to the location where your initialization scripts actually are installed. For example, if that location is /etc/rc.d/init.d, use these commands before installing the RPM to create /etc/init.d as a symbolic link that points there: shell> cd /etc shell> ln -s rc.d/init.d . However, all current major Linux distributions should support the new directory layout that uses /etc/init.d, because it is required for LSB (Linux Standard Base) compliance. If the RPM files that you install include MySQL-server, the mysqld server should be up and running after installation. You should be able to start using MySQL.
  38. 38. Note The accounts that are listed in the MySQL grant tables initially have no passwords. After starting the server, you should set up passwords for them using the instructions. 3.0 Introduction to MySQL Administrator (Installation) MySQL Administrator is a program for performing administrative operations, such as configuring, monitoring and starting and stopping a MySQL server, managing users and connections, performing backups, and a number of other administrative tasks. Most tasks can be performed using a command-line client such as mysqladmin or mysql, but MySQL Administrator has the following advantages: • Its graphical user interface makes it more intuitive. • It provides a better overview of the settings that are crucial for the performance, reliability, and security of your MySQL servers. • It displays performance indicators graphically, thus making it easier to determine and tune server settings. MySQL Administrator is designed to work with MySQL versions 4.0 and higher. 3.1 Installing Under Windows MySQL GUI Tools run on recent 32-bit Windows NT based operating systems, including Windows 2000, XP, and 2003. They don't run on Windows NT 4 and below Using the Windows Installer MySQL GUI Tools can be installed on all Windows operating systems using the Windows Installer (.msi) installation package. The MSI package is contained within a ZIP archive named mysql-gui-tools-version-win32.msi, where version indicates the MySQL GUI Tools version. To install MySQL GUI Tools, right click on the MSI file and select Install.
  39. 39. At the Setup Type window you may choose a complete or custom installation. If you do not wish to install all of the MySQL GUI Tools choose the custom option. Custom installation also gives you the option of installing support for languages other than English. MySQL GUI Tools supports, German, Greek, Japanese, Polish, and Brazilian Portuguese. Unless you choose otherwise, MySQL GUI Tools are installed in C:%PROGRAMFILES %MySQLMySQL Tools for version, where %PROGRAMFILES% is the default directory for programs on your machine and version is the version number of MySQL GUI Tools. The %PROGRAMFILES%directory might be C:Program Files or C:programme. 3.2 Installing Under Linux MySQL GUI Tools runs on Linux machines that have a graphical desktop installed. It is designed to run under the Gnome desktop with GTK2 and has been tested on Linux kernel versions 2.4 and 2.6. It should also run on other versions, and even on a number of Unix-like operating systems. 3.2.1 Installing the Generic Tarball The generic tar archive allows you to install MySQL GUI Tools on most Linux distributions. The tarball file is called mysql-gui-tools-version.tar.gz, where version indicates the MySQL GUI Tools version (for example, 5.0r3). To see all files in the tarball, run this command: shell> tar -tzf mysql-gui-tools-version.tar.gz To install MySQL GUI Tools, run this command: shell> tar --directory=/opt -xzvf mysql-gui-tools-version.tar.gz This installs the various application binaries in the directory, /opt/mysql-gui- tools-version. If you install MySQL GUI Tools to the opt directory, icons for use with desktop shortcuts or for creating menu items are found under the opt/mysql-gui-tools- version/share/mysql-gui directory. 3.2.2 RPM Installation In addition to a generic tarball, some distribution-specific RPMs are available. Currently these include Red Hat Enterprise Linux (RHEL) 3 and 4, Fedora Core 5 (FC5), and SuSE Linux 10.x. For FC5 and SuSE the gtkmm24 toolkit is a requirement for installing the
  40. 40. RPM version of MySQL GUI Tools. You may also need to install the widget for displaying HTML pages. On FC5 you may install these RPMs from the command line in the following way: shell> yum install gtkmm24 gtkhtml2 For installation on SuSE Linux: shell> yast2 -i gtkmm24 gtkhtml2 Note You may need root privileges to run the yast2 command. The Red Hat RPMs are self contained so no additional packages need to be installed. The RPM downloads are made up of the individual GUI Tools components combined into a single TAR archive. Extract the individual RPMs in the following way: shell> tar -zxf mysql-gui-tools-version.tar.gz This will decompress the RPM files to the current directory. Install all the RPM files by typing: shell> rpm -ivh mysql-*.rpm If you install the RPM files individually, you must install the mysql-gui-tools- version.rpm file first in order to satisfy dependencies. If you wish, you may install only one of the MySQL GUI Tools. For example, to install MySQL Administrator only, do the following: shell> rpm -ivh mysql-gui-toolsversion.rpm mysql- administratorversion.rpm Icons for use with desktop shortcuts or for creating menu items are found under the /usr/share/mysql-gui directory. 4.0 Running MySQL GUI Tools. 4.1 Running Under Windows. Under Windows, the names of the executable files in the MySQL GUI Tools suite are:
  41. 41. • MySQLAdministrator.exe • MySQLQueryBrowser.exe • MySQLWorkbench.exe • MySQLMigrationTool.exe Start any one of the MySQL GUI Tools by double clicking its desktop icon, or by selecting it from the Start menu. Alternatively, you can open a DOS window and start it from the command line. For example, you could run the MySQL Administrator in the following way: C:> "C:%PROGRAMFILES%MySQLMySQL Tools for versionMySQLAdministrator.exe" %PROGRAMFILES% is the default directory for programs on your machine, for example C:Program Files or C:programme. If your path contains spaces, you must enclose the command within quotation marks as shown above. 4.2 Connection Dialog Once MySQL Administrator has been started, it displays a connection dialog box. Specify the MySQL server you would like to connect to, the necessary credentials, and both the host and port. You may also specify a number of other options, if required. As an alternative to connecting to a running MySQL server, you can run MySQL Administrator in configure-service mode.
  42. 42. Note that MySQL Administrator will not work with MySQL servers prior to version 4.0. If you try to connect to an older server, an error message will appear, telling you that this is not possible. If the server connection is successfully established, all of the values filled in the fields of the connection dialog will be saved for future connections. The Password field, however, will always be empty: For security reasons, the password is not stored along with the other options, unless you explicitly specify. You can change any of the values in the connection profiles by overwriting the existing values with new ones. Similarly, if you select another connection profile, you can change any of its values. When you click the OK button after changing a profile's values, the changes are stored permanently if a successful connection to the MySQL server is established. However, the preferred method for changing a profile is to click the ... button next to the Connection drop-down box. That brings up an Options dialog window that has a Connections section for modifying connection profiles. 4.3 Server Connections Server connections allows you to view and manage the current connections to the server (also called threads). If you have the PROCESS privilege, you can see all threads. If you have the SUPER privilege, you can also terminate threads other than your own. (Note that the SUPER privilege is available for MySQL servers as of version 4.0.3 only.) Otherwise, you can see your own threads only.
  43. 43. 4.4 Threads Threads allows you to view all connections to the server (threads). By default, threads are sorted by their PID (MySQL process identification number), but you can change that order by clicking on the appropriate headings (User, Host, etc.). You can select one or more threads using the mouse or the keyboard. To reload the process list from the server, press the Refresh button. If you have selected one or more threads, you can terminate them by clicking the Kill Thread button, or by right-clicking on that thread. Remember that you need the PROCESS privilege to see threads other than your own, and the SUPER privilege to kill threads other than your own. Furthermore, note that MySQL Administrator imposes a restriction that prevents you from terminating your own threads. On Windows, using the Kill Thread button on your own threads has no effect; on Linux, that button is disabled when selecting your own threads. 4.5 User Connections. This tab displays all connections to the server (threads), but in a different way than the Threads tab does: You will see users rather than individual threads. The number of connections for each user is listed under Num.. Right-clicking on a username and selecting Show User Infos displays the Full Name and the Description, as specified in the User Information tab of the User Administration section. Initially, users are sorted by their MySQL Username, but you can change the order by clicking on the headings (Num., Full Name, or Description). Clicking on a username will display the individual threads of that user in the lower box of the tab, ordered by PID. Likewise, you can change the order by clicking on one of the headings. Clicking on a user will enable the Kill User button, allowing you to terminate all threads of that user with a single click. This command is also available by right clicking on the username. Clicking on an individual thread in the lower box enables the Kill Thread button, which is used to terminate a connection. This command is also available by right clicking on a thread. To reload the user list from the server, press the Refresh button. 4.6 User Administration This section shows how to administer existing users, add new users, and delete existing users. 4.6.1 User Accounts Existing users are listed in the lower left area of the sidebar. If there are many user accounts on your MySQL server, the field with the magnifying glass icon may be handy
  44. 44. for filtering the users you are looking for. Typing in t or T, for example, will set the filter to users whose names begin with a t. The filter works in a case-insensitive fashion. If you are an experienced MySQL user, you will notice that users are not listed in the typical MySQL way (user@host ), but rather with their usernames only. If double clicking on a username does not show subcategories for that user, this means that the user's privileges are not restricted to a specific host, or hosts. If there are subcategories, the user's privileges are restricted to a specific host, or set of hosts. You may assign various (and different) sets of privileges, depending on the host from which the user connects to the MySQL server. MySQL Administrator has a different concept of what a user is than MySQL has. In MySQL, a user is always identified by a username / host combination. This means that, for example, 'brian'@'%' may be a user completely different from 'brian'@'localhost' . The former might be Brian Miller , while the latter might be Brian Schultz . That distinction does not hold true for MySQL Administrator: User brian is always a particular user, no matter from which host he connects to the MySQL server. That said, 'brian'@'%' may still have privileges different from 'brian'@'localhost' . For example, you might have a user called superuser. If double clicking on that username shows two subcategories, localhost and athena, this means that the user has a specific set of privileges if he/she connects from localhost, and a (probably different) set of privileges if he/she connects from athena. Right clicking on a username, or on one of the subcategories a user might have, provides access to the following commands:
  45. 45. • Add a new User: Selecting this command adds a new user with the default name New User to the user list. You will have to fill in at least a username in the MySQL User field of the User Information tab, which, after applying this change, will also rename that user in the user accounts list. • Add Host from which the User can connect: Allows you to specify a host from which the user can connect. This command is unavailable if you highlight a subcategory. • Remove Host from which the User can connect: Allows you to remove a host from which the user can connect. If there are no sub-categories, the user will be removed (you will be prompted to confirm the removal). • Clone User: Makes a copy of the selected user, including all subcategories. The new user is called New User until you specify another name in the MySQL User field of the User Information tab. This command is useful for creating users with identical privileges. • Delete User: Allows you to delete the selected user. You will be prompted to confirm that you really want to delete that user. • Refresh User List: Rereads the user list from the MySQL server. This is helpful when other users (on other connections) are editing user accounts. Note that selecting that command will collapse all subcategories. 4.6.2 User Information The fields in this tab are unavailable unless you either click on a username in the User Accounts area of the sidebar, or create a new user in that sidebar or using the New User button on this tab. In the former case, the fields are filled with the information stored for that user, in the latter case, all fields are empty. Note that all fields will be stored only when you click the Apply Changes button. If you don't want to save your changes, click the Discard Changes button. 4.6.3 Schema Privileges Schema Privileges allows you to grant privileges on a schema level. In MySQL, a schema is the same as a database. To grant privileges for a specific database, click on the database name in the left box. (You cannot select more than one database at a time.) You may use wild cards to grant privileges on a number of schemata simultaneously. Use ‘%’ to replace multiple characters and ‘_’ to replace a single character. To use this feature, right click any database name in the schemata list, choose the Add Schema with Wildcards option from the pop-up menu and enter the pattern you wish to match. Entering m% for example, will add the entry, m% to the schemata list. Highlight this entry and any privileges granted will be granted for all schemata starting with the letter ‘m’.
  46. 46. 4.6.4 Global Privileges Global Privilege tab is available only if the Show Global Privileges checkbox in the Administrator Section of the Options dialog has been checked. Under Assigned Privileges, you find the global privileges assigned to the selected user. Global means that those privileges apply to the MySQL server in general (like the Shutdown privilege), or to all databases on the server (like the SELECT privilege). Privileges not assigned to the user are listed under Available Privileges. You can remove privileges by selecting them in the left box, and then clicking the > button. Removed privileges will appear in the Available Privileges box. You can assign privileges by selecting them in the Available Privileges box, and then clicking the < button. 4.6.5 Table Column Privileges. Table Privilege tab is available only if the Show Schema Object Privileges checkbox in the Administrator section of the Options dialog has been checked. It allows you to grant privileges on a table level or on a column level. To access the tables, double click on the schema (database) name containing that table. You will not see and cannot grant privileges on a schema level in this tab; if you want to do that, use the Global Privileges tab instead. Also, you cannot select more than one table at a time. If you want to grant privileges on a column level, double click on the table name; this will give you access to its columns. You cannot select more than one column at a time. Privileges not assigned to the user are listed under Available Privileges. You can remove privileges by selecting them in the left box, and then clicking the > button. Removed privileges will appear in the Available Privileges box. You can assign privileges by selecting them in the Available Privileges box, and then clicking the < button. 5. The MySQL System Tray Monitor The MySQL System Tray Monitor is a tool that allows you to monitor the status of your local mysql server through an indicator that resides in the system tray. The MySQL System Tray Monitor also gives quick access to the various MySQL GUI tools through its context menu. To start the MySQL System Tray Monitor, you can either execute the MySQLSystemTrayMonitor.exe application that resides in your MySQL Administrator installation directory, or choose the MySQL System Tray Monitor option of the Tools menu.
  47. 47. Once the MySQL System Tray Monitor is running, it resides in the system tray and provides visual status information for your MySQL server. A green icon is displayed at the top left corner of the MySQL System Tray Monitorif the MySQL server is running, and a red icon is displayed if the service is stopped. In addition, the CPU load may optionally be displayed along the right side of the MySQL System Tray Monitor. The MySQL System Tray Monitor If you right-click on the MySQL System Tray Monitor, a pop-up menu will appear, listing all installed MySQL services and their individual statuses. For each service, the following options are available: • Shutdown Instance: this will begin the shutdown operation on the selected running service. • Start Instance: this will start a currently stopped server instance. • Configure Instance: this will launch the MySQL Administrator in configure service mode for the currently selected instance. • Monitoring Options: currently the Monitoring Options submenu has one available option: Ignore Instance State. Ignore Instance State will cause the MySQL System Tray Monitor to stop monitoring the selected service. In addition to the service controls, you can also start the MySQL Query Browser and MySQL Administrator from the pop-up menu. The Manage MySQL Instances option of the Actions menu can be used to start MySQL Administrator in configure service mode so you can manage your server configurations. The Monitor Options menu has two options, which affect the general behavior of the MySQL System Tray Monitor. Display CPU Load determines whether the CPU usage is
  48. 48. displayed on the right of the MySQL System Tray Monitor. Launch Monitor after Login sets the MySQL System Tray Monitorto launch when you log into Windows. 6. Backup This section shows you how to create backup projects and to perform backups. This section will produce backup files that are plain text and composed of multiple SQL statements that can be executed to restore your database, similar to the output generated by the mysqldump utility. Existing backup projects are listed in the lower left area of the sidebar. If there are many backup projects, the field with the magnifying glass icon can be used to filter the projects you are looking for. Typing in t or T, for example, will set the filter to projects whose names begin with a t. The filter works in a case-insensitive fashion. You can update the list of backup projects by right clicking on a project and choosing the Refresh Backup Projects option from the drop-down menu. You can delete a backup project by right clicking on the project and choosing the Delete Backup Project(s) option from the drop-down menu. If you are not working from a previously saved backup project, click the New Project button to create a new backup project. You cannot begin configuring a backup operation without either loading an existing project or creating a new project. Once you have configured your backup project, you can click the Save Project button to save your project for future use. To start your backup, click the Execute Backup Now button. You will be prompted for a path and filename for the backup file, after which the backup operation will begin. 6.1 Backup Project The Backup Project tab allows you to set the name of your backup project and also determine what data will be backed up. You can name your project by filling out a name in the Project Name field. If you have enabled the Add Date/Time to Backup Files option in the Administrator Options dialog then the date and time of the backup will be appended to the project name automatically. Specify a name that clearly identifies the project, such as Full Backup.The project name may contain arbitrary characters, including spaces. To choose the databases and tables that will be backed up, select the database from the schemata list and click the > button. Once the database is in the Backup Content list, you can uncheck specific tables that you do not wish to back up.
  49. 49. The Backup Project tab allows you to set the name of your backup project and also determine what data will be backed up. You can name your project by filling out a name in the Project Name field. If you have enabled the Add Date/Time to Backup Files option in the Administrator Options dialog then the date and time of the backup will be appended to the project name automatically. 6.2 Advanced Options The Advanced Options tab allows you to configure advanced options that affect the way the backup operation behaves. These include concurrency controls, backup type, and output formatting. 6.2.1. Backup Execution Method The Backup Execution Method affects concurrency within the backup itself. InnoDb Online Backup will begin a transaction before reading from the tables. Because of the InnoDB versioning system this will allow all tables to be read in a consistent state. This method is recommended when backing up InnoDB tables. Lock all tables will cause all tables within the backup to be locked simultaneously to prevent writing. This will prevent users from writing to the tables during the backup operation and will ensure that the tables are in a consistent state. This option is recommended for MyISAM tables. Normal Backup will lock each table individually when performing the backup. While this can have less impact on the actions of users during the backup operation, these is a potential for tables to be backed up in an inconsistent state in relation to one another. This method is not recommended unless the risk of inconsistency is minimal. Online with binlog pos is the same as InnoDb Online Backup but also logs the current position within the binary log. Complete Backup overrides the table selection made in the Backup Project tab and backs up all tables in the selected schema. This option can be useful when scheduling the backup of a schema that changes regularly. 6.2.2. Output File Options The Output File Options section controls the formatting of the backup file. At present there is only one Backup Type available, the SQL Files format, which outputs a file similar to the output of the mysqldump utility.
  50. 50. No CREATEs will suppress CREATE DATABASE statements. This can be useful if you need to restore the data to a different database than it was backed up from. No EXTENDED INSERTS will supress the default behavior of combining multiple inserts into a single statement (for example INSERT INTO test VALUES ('1',Some data',2234),('2','Some More Data',23444)). While the EXTENDED INSERT syntax is more efficient both in terms of storage and execution, it is not compatible with most RDBMSes. Add DROP Statements adds DROP TABLE IF EXISTS statements to the backup file. Note If your backup project includes views then you must choose this option. Restoration of a view is a two step process that involves creating a dummy table with the same name as the view. This table must be dropped before the view can be recreated. Complete INSERTs will produce full INSERT statements that include a column list (i.e. INSERT INTO tablename(columnA, columnB) VALUES(valueA, valueB)). Without this option the column list will be omitted. Comment writes additional backup information to the backup file in the form of SQL comments. Fully Qualified Identifiers causes MySQL Administrator to write statements in the format, schema_name.table_name, instead of writing only the object name. (Under Linux this check box is labeled Don't write full path.) Don't check this option if you plan to restore your database objects to a different database. Compatibility mode creates backup files that are compatible with older versions of MySQL Administrator. ANSI Quotes will cause all table and database names to be quoted with ANSI style double quotes instead of backticks. Disable keys will add an ALTER TABLE ... DISABLE KEYS statement to the backup file before the INSERT statements that populate the tables. This allows for faster recovery by loading all data before rebuilding the index information
  51. 51. 7. Restore The Restore section helps with disaster recover by helping you restore backup files created using MySQL Administrator. The backup files created by MySQL Administrator are similar but not identical to those created by mysqldump. A consequence of the differences is that MySQL Administrator cannot read dump files created by mysqldump. 7.1 The General Tab In this tab, you specify which backup file should be restored, the character set and format, and the target location for restored tables. To set any options on this tab, you must first open a backup file by clicking the Open Backup File button at the bottom of the window. When all options are set, you can click the Start Restore button to begin the restore process. The following options are available: • File to restore: Specify the path and filename of the backup file. You can browse for that file by clicking the Open Backup File button. • Target Schema: You can choose the Original Schema option to have all tables restored into their original databases. You can also choose the New Schema ... option to restore all tables into a new database. Finally you can choose from one of the existing databases in the drop-down list to force all tables to be restored to that database. • Backup Type: At the moment, the only available option is SQL Files. Those are backup files containing SQL statements such as those produced by mysqldump. • Ignore Errors: Selecting this option allows a user to continue with the restore operation even if errors are encountered. However, results are not likely to be 100% correct. • Create database(s) if they don't exist: If a non-existent database is referenced it will automatically be created if this option is checked. • File Charset: Backup files created with MySQL Administrator are encoded in the utf8 character set. Backup files created with other tools such as winmysqladmin may be encoded with other character sets. Before a backup file can be successfully imported you will need to specify its character set. If you do not know the character set of your backup file, click the Auto-Detect Character Set button to have MySQL Administrator attempt to determine it automatically. 7.2 Restore Content Tab If you do not wish to restore all the databases or tables listed within your backup file, you can use the Restore Content tab to limit which databases and tables are restored.
  52. 52. To prevent a database or table from being restored, uncheck the box next to the object's name. After clicking the Analyze Backup File Content button, a list of all databases and tables contained within the backup file will be displayed. 8. Replication Status The Replication Status sections give you a visual overview of your MySQL replication master and slaves. The server status icons beside each machine tells you which slave machines are connected to the master and which ones are offline. 8.1 Configuring Replication Servers To use the Replication Status section you must be connected to the server that acts as the master in your replication scheme. Your MySQL servers must be version 4 or higher to use this feature. For a slave server to show in the Replication Status screen, it must register itself with the master server. To have a slave server register itself with the master, set the report-host option in your server configuration (my.cnf/my.ini) file
  53. 53. 8.2 Using the Replication Status Section. Once your servers are configured, they will appear in the Replication Status section, as seen in the following figure: All servers are listed under the Hostname column, along with their server ID, Port, and current status. New servers that are not currently being monitored will have an exclamation mark as their status symbol, and will be listed as a New Instance in the Status column of their entry. Servers that are currently being monitored and are online will have a green status icon and will be listed as Available in the Status column of their entry. Servers that are currently not in contact with the master server will have a red status icon and will be listed as Not Available. There will be a slight delay between a slave machine going offline and having its status updated to allow for an adequate timeout in the communications between master and slave. To start monitoring a new server that is not currently being monitored, click the Add Instance to Monitoring List button. To stop monitoring a server that is currently being monitored, click the Remove Instance from monitoring List button.
  54. 54. 9. Storage Engines MySQL supports several storage engines that act as handlers for different table types. MySQL storage engines include both those that handle transaction-safe tables and those that handle non-transaction-safe tables: • MyISAM manages non-transactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities. MyISAM is supported in all MySQL configurations, and is the default storage engine unless you have configured MySQL to use a different one by default. • The MEMORY storage engine provides in-memory tables. The MERGE storage engine allows a collection of identical MyISAM tables to be handled as a single table. Like MyISAM, the MEMORY and MERGE storage engines handle non- transactional tables, and both are also included in MySQL by default. Note The MEMORY storage engine formerly was known as the HEAP engine. • The InnoDB and BDB storage engines provide transaction-safe tables. InnoDB is included by default in all MySQL 5.0 binary distributions. In source distributions, you can enable or disable either engine by configuring MySQL as you like. • The EXAMPLE storage engine is a “stub” engine that does nothing. You can create tables with this engine, but no data can be stored in them or retrieved from them. The purpose of this engine is to serve as an example in the MySQL source code that illustrates how to begin writing new storage engines. As such, it is primarily of interest to developers. • NDBCLUSTER is the storage engine used by MySQL Cluster to implement tables that are partitioned over many computers. It is available in MySQL 5.0 binary distributions. This storage engine is currently supported on a number of Unix platforms. There will be support for this engine on other platforms, including Windows, in future MySQL releases. • The ARCHIVE storage engine is used for storing large amounts of data without indexes with a very small footprint. • The CSV storage engine stores data in text files using comma-separated values format. • The BLACKHOLE storage engine accepts but does not store data and retrievals always return an empty set. • The FEDERATED storage engine was added in MySQL 5.0.3. This engine stores data in a remote database. Currently, it works with MySQL only, using the MySQL C Client API. In future releases, we intend to enable it to connect to other data sources using other drivers or client connection methods.
  55. 55. When you create a new table, you can specify which storage engine to use by adding an ENGINE or TYPE table option to the CREATE TABLE statement: CREATE TABLE t (i INT) ENGINE = INNODB; CREATE TABLE t (i INT) TYPE = MEMORY; The older term TYPE is supported as a synonym for ENGINE for backward compatibility, but ENGINE is the preferred term and TYPE is deprecated. If you omit the ENGINE or TYPE option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the --default-storage-engine or --default-table-type server startup option, or by setting the default- storage-engine or default-table-type option in the my.cnf configuration file. You can set the default storage engine to be used during the current session by setting the storage_engine or table_type variable: SET storage_engine=MYISAM; SET table_type=BDB; When MySQL is installed on Windows using the MySQL Configuration Wizard, the InnoDB storage engine can be selected as the default instead of MyISAM. To convert a table from one storage engine to another, use an ALTER TABLE statement that indicates the new engine: ALTER TABLE t ENGINE = MYISAM; ALTER TABLE t TYPE = BDB; If you try to use a storage engine that is not compiled in or that is compiled in but deactivated, MySQL instead creates a table using the default storage engine, usually MyISAM. This behavior is convenient when you want to copy tables between MySQL servers that support different storage engines. (For example, in a replication setup, perhaps your master server supports transactional storage engines for increased safety, but the slave servers use only non-transactional storage engines for greater speed.) This automatic substitution of the default storage engine for unavailable engines can be confusing for new MySQL users. A warning is generated whenever a storage engine is automatically changed. For new tables, MySQL always creates an .frm file to hold the table and column definitions. The table's index and data may be stored in one or more other files, depending on the storage engine. The server creates the .frm file above the storage engine level. Individual storage engines create any additional files required for the tables that they manage.
  56. 56. A database may contain tables of different types. That is, tables need not all be created with the same storage engine. Transaction-safe tables (TSTs) have several advantages over non-transaction-safe tables (NTSTs): • They are safer. Even if MySQL crashes or you get hardware problems, you can get your data back, either by automatic recovery or from a backup plus the transaction log. • You can combine many statements and accept them all at the same time with the COMMIT statement (if autocommit is disabled). • You can execute ROLLBACK to ignore your changes (if autocommit is disabled). • If an update fails, all of your changes are reverted. (With non-transaction-safe tables, all changes that have taken place are permanent.) • Transaction-safe storage engines can provide better concurrency for tables that get many updates concurrently with reads. You can combine transaction-safe and non-transaction-safe tables in the same statements to get the best of both worlds. However, although MySQL supports several transaction- safe storage engines, for best results, you should not mix different storage engines within a transaction with autocommit disabled. For example, if you do this, changes to non- transaction-safe tables still are committed immediately and cannot be rolled back.. Non-transaction-safe tables have several advantages of their own, all of which occur because there is no transaction overhead: • Much faster • Lower disk space requirements • Less memory required to perform updates 9.1 The MyISAM Storage Engine MyISAM is the default storage engine. It is based on the older ISAM code but has many useful extensions. (Note that MySQL 5.0 does not support ISAM.) Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. To specify explicitly that you want a MyISAM table, indicate that with an ENGINE table option: CREATE TABLE t (i INT) ENGINE = MYISAM;
  57. 57. The older term TYPE is supported as a synonym for ENGINE for backward compatibility, but ENGINE is the preferred term and TYPE is deprecated. Normally, it is unnecesary to use ENGINE to specify the MyISAM storage engine. MyISAM is the default engine unless the default has been changed. To ensure that MyISAM is used in situations where the default might have been changed, include the ENGINE option explicitly. You can check or repair MyISAM tables with the mysqlcheck client or myisamchk utility. MyISAM tables have the following characteristics: • All data values are stored with the low byte first. This makes the data machine and operating system independent. The only requirements for binary portability are that the machine uses two's-complement signed integers and IEEE floating- point format. These requirements are widely used among mainstream machines. Binary compatibility might not be applicable to embedded systems, which sometimes have peculiar processors. There is no significant speed penalty for storing data low byte first; the bytes in a table row normally are unaligned and it takes little more processing to read an unaligned byte in order than in reverse order. Also, the code in the server that fetches column values is not time critical compared to other code. • All numeric key values are stored with the high byte first to allow better index compression. • Large files (up to 63-bit file length) are supported on filesystems and operating systems that support large files. • There is a limit of 232 (~4.295E+09) rows in a MyISAM table. If you build MySQL with the --with-big-tables option, the row limitation is increased to (232)2 (1.844E+19) rows. Binary distributions for Unix and Linux are built with this option. • The maximum number of indexes per MyISAM table is 64. This can be changed by recompiling. Beginning with MySQL 5.0.18, you can configure the build by invoking configure with the --with-max-indexes=N option, where N is the maximum number of indexes to permit per MyISAM table. N must be less than or equal to 128. Before MySQL 5.0.18, you must change the source. The maximum number of columns per index is 16. • The maximum key length is 1000 bytes. This can also be changed by changing the source and recompiling. For the case of a key longer than 250 bytes, a larger key block size than the default of 1024 bytes is used.