Summer 2008 Issue 5

S MySQL® Magazine
News, articles and feedback for MySQL database administrators and developers using MySQL on a daily basis to provide some of the best database infrastructure available.

INSIDE THIS ISSUE
2 SQLYog Enterprise Edition Version 6.55 Review 6 10 Ma'atkit Toolkit Tutorial: mk-table-checksum 13 Command Line mysql Client Options 21 MySQL Magazine’s 2008 Annual Usage Survey 22 news 42 log-bin

REGULAR FEATURES
Coding Corner

Page 2

Summer 2008

MySQL Magazine

SQLYog Enterprise Edition Version 6.55 Review
By Jonathan Cua This software is one of the most popular GUI-based tools for MySQL. Most of the features of the software are geared to help the daily work of DBAs and developers. The software is rich in features and therefore this review will only highlight some of the cool capabilities.

Connection to Remote Servers
Most companies require you to use the ssh protocol to access their servers. While it is easy to setup your own ssh tunnel to connect to your remote database, it is quite cumbersome to do that. SQLYog allows you to easily do this and lets you save your secure MySQL connection. I use this all the time and I do not even think about ssh tunneling anymore. On the downside, when I tried to connect to another database, the software opened a separate window for me. This made it difficult for me to switch from one window to another. This can be annoying if you want to compare two databases but it could also be a security measure so that you do not accidentally apply the wrong SQL statements to the wrong database.

Scanning Table Structures
tables then it becomes somewhat annoying.

If you want to find out the structure of a table, you typically have to type several commands from the

MySQL command line. Certainly there is nothing difficult about this, but if you are going to do this for several One nice thing about this software is that you can easily scan your database for information. Here is a quick example. Let's say that you have several tables in a database with multiple columns, and you want to query your database. If you are using the tables command status, line, show you fields, would show probably use the following: show create table, and show keys. SQLyog gives you the ability to see your table information as soon as

SQLYog Review continues on next page

Page 3

Summer 2008

MySQL Magazine

SQLYog Review from previous page you connect to your database. When you click on a table you immediately see the table definition, indexes and columns associated with it. SQLyog actually runs all the above commands in the background so that it can quickly show you the table structure at once. You can imagine the time that you can save without typing all of the above commands. Also, when you are trying to write your SQL logic, you can ignore the needing to issue a “show fields” command in order to get the proper spelling of a column.

Multiple Ways to Create SQL Queries
There are two ways to create queries in SQLyog.

1. TYPE THE QUERY IN A QUERY TAB WINDOW WITH THE AID OF AUTO-COMPLETE AND SQL SYNTAX TEMPLATE.
Unlike where you the MySQL to command type line have everything

correctly (SQL code, column names, table names) SQLyog helps you by providing an auto-complete feature where you simply click on the TAB button and it will complete the word that you are typing. This could be a SQL function, column name, or table name. Also, how many times have you forgotten the syntax of a SQL command and you had to search for the proper syntax of it? SQLyog has a built-in feature where you can simply insert SQL templates that give you the proper syntax ready for use.

2. USE THE QUERY BUILDER TO CREATE THE QUERY.
This involves dragging the table from the schema objects to a blank window. You can then join tables, specify filters, group the columns, and arrange the sort order. The software will build the equivalent SQL command for you and all of this can be done without typing a single SQL code.

SQLYog Review continues on next page

Page 4

Summer 2008

MySQL Magazine

SQLYog Review from previous page

Data Modeling

SQLyog provides a visual schema designer where you can create your tables, design the relationships and

it will automatically update your database. One nice thing about this feature is that when I want to see the relationship of two or three tables I just drag them in the browser window and the software will show me the visual relationship of the tables. If you are building an Entity Relationship Diagram (ERD) for a big database, then you would probably use another software. But I find this feature of SQLyog quite handy as I do not have to rely on another software to create a small ERD.

Database Management

Managing the database is quite easy with this

software. I was able to create new tables, manage indexes, add users and remove their permissions without typing any SQL commands. It is all point and click. It also supports the following features: copying of database to different hosts, creating duplicates of tables, renaming of tables, re-ordering of the columns, and changing the engine type of the database. What made this easy is that the software will guide you on what you have to do, so when you want to create copies of your tables, it is simply a matter of just clicking on that option. Backups with SQLyog were easy as well and I found no difference between doing backups on SQLyog or the Windows scheduler to run backup and emails you of the result of the backup. mysqldump. An additional feature is that SQLyog uses

I tested this feature by letting the software save my backup scheduler configuration; the software stored the information in an XML file where it contained my database username, database password, email address, and email password all in plain text! I have tried to work around this problem but I could not find a way to solve this.

Database and Structure Synchronization
each other.

SQLyog allows you to synchronize two different databases (both structure and data). It actually creates

the corresponding SQL commands so that if executed the two databases would become synchronized with I tested this and I was satisfied with the SQL output of the software. It was able to synchronize two different databases with little effort on my part. The tool has a wizard that will guide you step-by-step on what to do. It was simply selecting which database and which tables to synchronize and it did its job. I use this all the time when releasing new schema into production. This tool makes it easy to apply the necessary SQL commands to make the production schema the same as the development schema.

SQLYog Review continues on next page

for a large database. it has a wizard that will guide you on what you need to do. Also. Although SQLyog does not provide anything unique in terms of features (there are equivalent scripts or tools out there that will do the same job). .webyog. So.com. For more information. I would be hesitant to completely rely on this feature. I have not tested this on a large database and I do not know how the software will respond to a larger dataset. About the Author Jonathan Cua is a senior database administrator with over 10 years of experience in open source technology. please visit the website: http://www. I have tried this feature a couple of times and it seems to work just fine. Just like the other features. instead of doing everything in one big step and finding out in the end that something was wrong in the beginning. Conclusion This software provides a nice tool for MySQL DBAs and developers. I would probably do the migration in small steps such as making sure that the old and new column definitions match.Page 5 Summer 2008 MySQL Magazine SQLYog Review from previous page Migration Toolkit This feature allows you to move non-MySQL data into your MySQL database. large databases and data management systems. SQLyog attempt to provide an all-in-one solution.

Page 6 Summer 2008 MySQL Magazine C o d i n g o r n e r A MySQL query might call up hundreds of data columns and millions of data rows. and logical branching . no algorithm can capture all the possibilities.00 | | 1 | 7000.(1. Then why are so many queries hard to write? Call it the craftsman’s dilemma.(1. (10000.5000). union . INSERT INTO comms VALUES (0. but in the salesperson’s favor.2). As Kurt Gödel proved. Calculation of these commissions is stepwise.(2.25). variety. commend DECIMAL(10. aggregation.2) ).15). ( 50000.00 | | 1 | 5000.9000).(2. To get better at writing queries is to get better at the most famous problem-solving meta-method in the world: divide and conquer.60000. +------------+----------+ | employeeID | sales | +------------+----------+ | 1 | 2000. sales decimal(10.50000.00 | | 2 | 9000.2).12000).artfulsoftware.10).5).30). comms. restriction . The set of tools is small and the rules for using them are few. (40000. How is it done in MySQL? For an example assume the following tables for employee sales and commission rates: DROP TABLE IF EXISTS sales. Some firms motivate their sales forces with graduated sales commissions—like the graduated income tax. but it will use seven basic operations at most—selection. Every computer-savvy bookkeeper on the planet knows how to do this in a spreadsheet. pct INT ).7000).15000). (20000. By Peter Brawley http://www. Here is a case in point. (30000. INSERT INTO tblsales VALUES (1.30000. complexity and disguise.20). CREATE TABLE sales( employeeID int.00 | +------------+----------+ CREATE TABLE comms( commstart DECIMAL(10.40000.00 | | 2 | 12000. but problems come in unlimited size.(2.2000). SELECT * FROM tblsales. Divide and Conquer division . range by range. join .20000.10000.com Divide and Conquer continues on next page .00 | | 2 | 15000.

00 | 50000. base amount = 0 if amt <= commend.00 | 30000.00 | 30000. IF( s. base amount = amt .00 | 40000. base amount = commend .00 | 30 | +-----------+----------+-----+ One atom of this problem molecule is how to apply one commission range (commstart to commend) to one sales amount (amt).00 | 30000.00 | 10 | | 1 | 14000.commstart.00 | 20000.00 | 10000.00 | 0.amt <= c.00 | 10 | | 20000.commstart ) A second atom is application of every commission range row to every sales amount.00 | 30000.00 | 20000. c.00 | 25 | | 2 | 36000.SUM(sales) AS amt FROM sales GROUP BY employeeID ) AS s CROSS JOIN comms c ORDER BY s.00 | 20000.00 | 20 | | 2 | 36000.00 | 20000.00 | 40000.c.c.00 | 15 | | 1 | 14000.commend .00 | 30 | +------------+----------+-----------+----------+-----+ Divide and Conquer continues on next page .00 | 50000.amt < c. +-----------+----------+-----+ | commstart | commend | pct | +-----------+----------+-----+ | 0.commstart.00 | 15 | | 30000.00 | 60000.00 | 15 | | 2 | 36000. 0.00 | 50000.00 | 30000.Page 7 Summer 2008 MySQL Magazine Divide and Conquer from previous page SELECT * FROM comms. 2. if amt < commstart. s.00 | 10000.00 | 5 | | 2 | 36000.amt .00 | 20000. +------------+----------+-----------+----------+-----+ | employeeID | amt | commstart | commend | pct | +------------+----------+-----------+----------+-----+ | 1 | 14000. 3.commstart if amt > commend.00 | 10000.00 | 5 | | 10000.00 | 5 | | 1 | 14000.commstart It is basic branching logic: IF( s.00 | 10 | | 2 | 36000.00 | 0.00 | 25 | | 1 | 14000.00 | 20 | | 1 | 14000.00 | 50000.00 | 10000. c.00 | 60000.00 | 20 | | 40000.00 | 40000.00 | 30 | | 2 | 36000.00 | 50000.00 | 25 | | 50000. There are three cases to cover: 1.00 | 40000.commstart.commend. That is a basic pattern ) we covered in last issue's Coding Corner—the CROSS JOIN: SELECT * FROM ( SELECT employeeID.employeeID.00 | 40000.00 | 60000.00 | 10000.

00 | 0.00 | 10000.00 | | 2 | 36000.employeeID. s.00 | 20 | 0.00 | 40000.00 | 30000. Peter Brawley is President of Artful Software Development and co-author with Arthur Fuller of Get It Done With MySQL 5 (http://www. c.00 | | 2 | 36000.00 | 10000.00 | 30 | 0.amt <= c.00 | 10 | 1000.00 | 10000. IF( s.00 | +----+----------+----------+----------+----------+-----+------------+ Finally.commend-c.commstart.00 | +------+----------+------------+ The more query puzzles you solve.00 | | 1 | 14000.00 | 20000. the better you get at dividing them into kernels which resolve to basic methods. s. 2 ) AS Commission FROM ( SELECT employeeID.00 | 10000. IF( s.artfulsoftware.amt-c.s.commend-c.commstart.commend end.amt <= c.00 | 50000.00 | 0.00 | 0. SUM(sales) AS amt FROM sales GROUP BY employeeID ) AS s JOIN comms AS c ORDER BY s.00 | | 2 | 36000.00 | 20 | 1200.00 | 0.commend. c.00 | 20000.commstart.00 | 20000.00 | 6000. 0.00 | | 2 | 36000. IF( s.amt-c.employeeID.00 | 4000.00 | 10000.00 | | 2 | 36000.amt < c.00 | 60000.amt<=c.employeeID AS ID. +----+----------+----------+----------+----------+-----+------------+ | ID | amt | start | end | base | pct | commission | +----+----------+----------+----------+----------+-----+------------+ | 1 | 14000.00 | | 1 | 14000.00 | | 1 | 14000.00 | 40000.00 | 30000.pct/100 ).00 | 10000.commstart. sum and round the result: SELECT s.c.00 | 15 | 0.00 | | 1 | 14000.00 | 5 | 500.Amt. IF( s.00 | 0. s.00 | 60000.00 | 30000.amt. c.Page 8 Summer 2008 MySQL Magazine Divide and Conquer from previous page How do we plug the formula into the join? Add the formula to the SELECT list twice—for base amount and for commission: SELECT s.commstart.com).amt-c. IF( s.commstart)) * c.00 | 900. pct.00 | 10000. +------+----------+------------+ | ID | Amt | Commission | +------+----------+------------+ | 1 | 14000.00 | 50000.amt<=c.commstart start. s.00 | 15 | 1500.commstart.employeeID ID.commstart ) ) * pct / 100 AS commission FROM ( SELECT employeeID.c.amt<c.00 | 50000.0.00 | 0.00 | 50000.00 | 0.00 | | 2 | 36000.00 | 30 | 0. ROUND( SUM( IF(s.00 | | 1 | 14000.00 | 4200.00 | 10 | 400.00 | 20000.commend.commstart ) ) AS base.00 | 30000.00 | 5 | 500. c. 0.00 | 40000.commstart.00 | 0.00 | 25 | 0. About the author .SUM(sales) AS amt FROM sales GROUP BY employeeID ) AS s JOIN comms c GROUP BY s.00 | 25 | 0.commend-c.00 | 40000.00 | | 2 | 36000.commend.00 | 10000.

That's Their Problem. reporting and analysis Self-tuning design supports ad hoc queries Scalability into the terabytes Small footprint with dramatic power and cooling savings Read the Kickfire white paper to find out how to slash hardware buildout: http://www. · · · · 10x .100x improvements in query. Kickfire Database Appliance 126:5 Ratio Kickfire delivers the first high-performance database appliance for MySQL.com/index.php?option=com_content&task=view&id=16&Itemid=20 .kickfire.Page 9 Summer 2008 MySQL Magazine Our Competition is Big. bringing the power of the world's largest commercial query processing systems to your world.

`this_crc` char(40) NOT NULL. `this_cnt` int(11) NOT NULL. `boundaries` char(64) NOT NULL. Your option. Included in the maatkit toolkit (http://maatkit. etc. This can be very helpful in providing an accurate picture of your results. `master_cnt` int(11) default NULL. it is possible (and Want to learn about MySQL? For free? Sessions scheduled every Thursday at 15:00 CET MySQL University is in session! http://forge. The create command for this table should be: CREATE TABLE `checksum` ( `db` char(64) NOT NULL. Fortunately. It doesn’t have to be in the test database by the way. This will mean that a table doesn’t get blocked for too long a period of time. not only did he point out the problem. It can tell you which tables on the master and and slave are out of sync and even tell you within a fair degree what rows are out of sync.checksum localhost What are we doing here? Well.`tbl`.xaprb. `chunk` int(11) NOT NULL. Just be sure to specify the right database when running the mk-table-sync command.sf. You can put it wherever you want. have warm fail-over if you have a hardware failure on the master.com/wiki/MySQL_University mk-table-checksum continues on next page .000 rows (in this case) that they should be chunked — broken apart — when processing. Replication between the master and slave is fairly easy to set up. It just specifies the location of the master server. `tbl` char(64) NOT NULL. he provides a fix for the problem. In this case. I ran the command on the master server itself so localhost was specified. the chunksize option specifies that if tables are larger than 500.checksum table to store results in. `master_crc` char(40) default NULL. Here is an example run: mk-table-checksum –chunksize 500000 –replicate=test.`chunk`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1. The replicate option specifies that you are wanting the checksum tool to use the test. This provides the ability to easily perform backups. The final option is really easy. however as Baron Schwartz points out here: http://www.com/blog/2007/11/08/how-mysql-replication-got-out-of-sync/ probably quite common) for a master and slave to “drift” out of sync. PRIMARY KEY (`db`. `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP.Page 10 Summer 2008 MySQL Ma’atkit Toolkit Tutorial: mk-table-checksum By Keith Murphy Most production environments have a master/slave setup of servers.net) is the mk-tablechecksum tool (and the related tool mktable-sync which we won’t be discussing in this tutorial).mysql.

On database_1 I have two tables that are out of sync. Essentially the udf provides a replacement for the md5 hash function in MySQL.or you can use the mk-table-sync tool to do this for you.so) to the /lib directory and then run the command: mysql mysql -e “CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME ‘fnv_udf. there are nineteen fewer rows in the db table and one less row in the user database.gz file that is distributed from the maatkit website. This is because I have different permissions on my master and slave servers.cc The instructions are included in the source code. The two table_1 tables (on the master and slave) have the same row count (shown by the cnt_diff column). the crc_diff column shows that there are differences in the contents of the columns on the two tables. Here are the results: server db3 db6 checksum w/md5 17m10.checksum –replcheck 2 localhost This will give you the results you want. In the included files there is a udf directory with one file. You can use this to figure out the exact problem yourself. On two servers I ran the mk-table-checksum tool with the default setup and then installed the udf and re-ran the checksum tool.slave DB TBL CHUNK CNT_DIFF CRC_DIFF BOUNDARIES database_1 table_1 0 0 1 `clientid` < 184723 database_1 table_2 0 0 1 `clientid` < 184721 mysql db 0 -19 1 1=1 mysql user 0 -1 1 1=1 This shows that there were some differences on the slave. To compile “just”: gcc -fPIC -Wall -I/usr/include/mysql -shared -o fnv_udf. Just download and unzip/untar. In the mysql database. Once it is done executing and your slave has caught up (if it lagged behind the master) then you just run the following: mk-table-checksum –replicate=test. on the slave. There is a custom udf (user defined function) that Baron Schwartz programmed for use in the maatkit toolkit. So how do you set it up? The source code is included in the tar. The boundaries column show you which chunk of the table that the differences are located in.checksum –replcheck 2 localhost Differences on h=server.so’” mk-table-checksum continues on next page .090s 53m58.368s Clearly it is a great benefit to use this udf if you are running table checksums. Once you have it compiled. However. just copy the resultant file (fnv_udf.so fnv_udf. Here is some sample output: mk-table-checksum --replicate=test.Page 11 Summer 2008 MySQL mk-table-checksum continued from previous page It will take a while for this command to run if your databases are of a significant size. This custom function provides an impressive speedup.719s checksum w/fvn 5m0.220s 112m21.

mysql. Keith Murphy is a MySQL database administrator for The Pythian Group. ‘world’). tools. software previews. and projects by and for the MySQL community. This should returns some results if everything is done properly. To test.com/blog/2008/03/09/a-very-fast-fnv-hash-function-for-mysql About the author Magazine. Baron has an excellent background post on the fvn udf here: http://www. opinions of The Pythian Group.com/ to see what’s being forged! . worklogs. Once your MySQL server “sees” the new udf maatkit will begin using it automatically. log into mysql and make this call: mysql> SELECT FNV_64(’hello’.xaprb.Page 12 Summer 2008 MySQL mk-table-checksum continued from previous page This adds the function to your MySQL server setup. He is also the editor of MySQL The views and opinions expressed in this article are the author’s own and may not reflect the views and Are You Forging? The MySQL Forge is the premier place for code. Visit http://forge.

improve your interactive and batch processing experiences.' or '\h' for help.45-community-nt-log MySQL Community Edition (GPL) Type 'help. Your MySQL connection id is 687673 Server version: 5.com The mysql client has many other useful options. and change how the mysql client uses memory.sock -p -psecret --password='foo!' Example -u sheeri --user=webuser -h 192." +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | sakila | | test | +--------------------+ mysql options continues on next page . host can be a short hostname. When thinking of the mysql command line client. Connectivity Options to MySQL Option -u uname -h host Long Option Name --user=uname --host=host By Sheeri K. Specify port Specify socket. Type '\c' to clear the buffer. the mysql command line client can also be used to process a batch of queries. -p -ppass -P portnum -S file --port=portnum --socket=file --password=pass Enclose pass in quotes if it has special characters. Some options are similar to commands that can be run in the interactive mysql shell. a fully qualified domain name (FQDN) or an IP address.bar.1. file can be a relative or absolute path to the socket -P 3307 --port=3308 -S /tmp/mysql. or \g. Batch Options The –-execute option (short name -e) will process a batch list of one or more queries. These options are boring because they do not improve your experience with the command line client: Description Specify username Specify database server.168.0.100 --host=foo. ask for password interactively. Cabral The most commonly used options for the mysql command line client are the connectivity options.Page 13 Summer 2008 MySQL Command Line mysql Client Options Table 1. mysql> However.sock --socket=my. If no password specifed. provided on command line: shell> mysql -u root -prootpass --execute="SHOW DATABASES. Others provide ways to change the formatting of the output. you probably think of the interactive shell: Welcome to the MySQL monitor. Commands end with .

>> batch. shell> mysql -u root -prootpass < batch. To get non-table formatting using the execute option. shell> echo “SHOW DATABASES” | mysql -u root -prootpass Database information_schema mysql sakila test shell> echo SHOW DATABASES.sql SHOW DATABASES. +------------------------+ | user | +------------------------+ shell> You can also run a batch commands by redirecting SQL commands to the mysql command line client tool.sql Database information_schema mysql sakila test Tables_in_mysql (USER) user Notice that the output is formatted differently.sql && echo SHOW TABLES LIKE 'USER'.sql && echo USE mysql. each on a new line. This is because redirected commands act as if they were in “batch mode”. >> batch. The -B option (long format --batch) disables interactive mode and enables the --silent option. SHOW TABLES LIKE 'user'. USE mysql." Database information_schema mysql sakila test mysql options continues on next page . they will likely work on | Tables_in_mysql (user) | Solaris and Mac OS X as well. use either the -B or the --silent option: shell>mysql -u root -prootpass -B --execute="SHOW DATABASES. SHOW TABLES LIKE 'USER'. >> batch. USE mysql. This can be done with pipes or using the redirection operator.Page 14 Summer 2008 MySQL mysql options continued from previous page shell> mysql -u root -prootpass -e "SHOW DATABASES.sql shell> more batch. The --silent option replaces the default table formatting of the output with tab-separated rows." +--------------------+ | Database | +--------------------+ | information_schema | Note: All the examples in this | mysql | | sakila | article have been designed and | test | tested to work on both Linux and +--------------------+ +------------------------+ Windows.

Database information_schema mysql sakila test mysql> exit shell> mysql options continues on next page .com/mag/ http://www.Page 15 Summer 2008 MySQL mysql options continued from previous page shell>mysql -u root -prootpass --silent -e "SHOW DATABASES. approved nor controlled by MySQL AB.TcationTreas>mysql -u root -prootpass -t < batch. The good news is that the --silent option works with the interactive mysql command line as well. Note that in silent mode.net Output Options If you find yourself copying and pasting output frequently.cnf and ~/. simply put “silent” in the [client] directive of a configuration file. you probably curse MySQL's table-style formatting.sql +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | sakila | | test | +--------------------+ +------------------------+ | Tables_in_mysql (user) | +------------------------+ | user | +------------------------+ Note that all of the options to mysql can be specified in the [mysql] or [client] group of an option file. and the content is not endorsed. So if you want to disable table formatting all the time.in front of the long name. MySQL logos and the Sakila dolphin are registered trademarks of MySQL AB in the United States. the usual MySQL header showing information like the version. use the -t option (long format --table): C:\Documents and Settings\Owner.my. the European Union and other countries. Simply use the long name and omit the -.mysqlzine.ini. such as /etc/my. MySQL Magazine is not affiliated with MySQL AB. MySQL.cnf and my. Have a topic for a future edition of the MySQL Magazine? Send articles and ideas to: Keith Murphy. Editor bmurphy@paragon-cs. connection ID and welcome message are suppressed. as well as the “Bye” message upon exit: shell>mysql -u root -prootpass --silent mysql> SHOW DATABASES." Database information_schema mysql sakila test If you want table-style formatting in batch mode. reviewed.com Download previous editions of the MySQL Magazine at: and http://paragon-cs.

or \g. information_schema mysql sakila test mysql> exit shell> The \G command in the interactive mysql command line shell is very useful – when used at the end of a query instead of . mysql> show databases. Type '\c' to clear the buffer.0.Page 16 Summer 2008 MySQL mysql options continued from previous page While using silent or table mode. This vertical option can be used interactively or in batch mode: shell> mysql -u root -prootpass --vertical mysql -e "SHOW TABLE STATUS LIKE 'user'.' or '\h' for help.45-community-nt-log MySQL Community Edition (GPL) Type 'help.00 sec) mysql> exit Bye shell>mysql -u root -prootpass --silent --skip-column-names mysql> show databases. +--------------------+ | information_schema | | mysql | | sakila | | test | +--------------------+ 4 rows in set (0. Your MySQL connection id is 21 Server version: 5. row *************************** Name: user Engine: MyISAM Version: 10 Row_format: Dynamic Rows: 2 Avg_row_length: 104 Data_length: 312 Max_data_length: 281474976710655 Index_length: 2048 Data_free: 104 Auto_increment: NULL Create_time: 2007-07-04 09:49:18 Update_time: 2007-09-23 16:14:15 Check_time: NULL Collation: utf8_bin Checksum: NULL Create_options: Comment: Users and global privileges mysql options continues on next page shell> . *************************** 1. The --skipcolumn-names option does just that: shell> mysql -u root -prootpass --skip-column-names Welcome to the MySQL monitor. or \g. Commands end with . it outputs a query in vertical format. it may be desirable not to have the column names printed. The -E option (long format --vertical) makes the output print vertically without having to use the \G command with every query.

or g/2001/XMLSchema-instance"> <row> <field name="Name">user</field> <field name="Engine">MyISAM</field> <field name="Version">10</field> <field name="Row_format">Dynamic</field> <field name="Rows">2</field> <field name="Avg_row_length">104</field> <field name="Data_length">312</field> <field name="Max_data_length">281474976710655</field> <field name="Index_length">2048</field> <field name="Data_free">104</field> <field name="Auto_increment" xsi:nil="true" /> <field name="Create_time">2007-07-04 09:49:18</field> <field name="Update_time">2007-09-23 16:14:15</field> <field name="Check_time" xsi:nil="true" /> <field name="Collation">utf8_bin</field> <field name="Checksum" xsi:nil="true" /> <field name="Create_options"></field> <field name="Comment">Users and global privileges</field> </row> </resultset> mysql options continues on next page . mysql> show tables. SHOW TABLE STATUS LIKE 'user'.w3.45-community-nt-log MySQL Community Edition (GPL) Type 'help.00 sec) mysql> exit Bye shell> mysql -u root -prootpass --xml -e "USE mysql. <?xml version="1.Page 17 Summer 2008 MySQL mysql options continued from previous page If you want to have fancier output. Type '\c' to clear the buffer. or \g. Your MySQL connection id is 28 Server version: 5. respectively: shell>mysql -u root -prootpass --html mysql Welcome to the MySQL monitor.0.' or '\h' for help. Commands end with .0"?> <resultset statement="SHOW TABLE STATUS LIKE 'user'" xmlns:xsi="http://www. the -H option (long format html) and -X option (long format xml) will output html and xml styles. <TABLE BORDER=1><TR><TH>Tables_in_mysql</TH></TR><TR><TD>columns_priv</TD></TR> <TR><TD>db</TD></TR><TR><TD>func</TD></TR><TR><TD>help_category</TD></TR> <TR><TD>help_keyword</TD></TR><TR><TD>help_relation</TD></TR><TR><TD>help_topic</TD></TR> <TR><TD>host</TD></TR><TR><TD>proc</TD></TR><TR><TD>procs_priv</TD></TR> <TR><TD>tables_priv</TD></TR><TR><TD>time_zone</TD></TR> <TR><TD>time_zone_leap_second</TD></TR><TR><TD>time_zone_name</TD></TR> <TR><TD>time_zone_transition</TD></TR><TR><TD>time_zone_transition_type</TD></TR> <TR><TD>user</TD></TR></TABLE> 17 rows in set (0.

--tee=name will append output into the outfile specified as well as displaying it on screen. This sets the mysql prompt to “name”. The most common usage is --pager=more (or less).45-community-nt-log MySQL Community Edition (GPL) Type 'help.mysql. mysql [localhost] {root} ((none)) > use mysql. Diego Medina has a sample prompt on the MySQL Forge at: http://forge. Your MySQL connection id is 44 Server version: 5. which are similar to the mysql interactive commands tee and notee. which specifies the pager to use to display results. but you can also use any appropriate shell command: mysql options continues on next page .0/en/mysql-commands. or \g. Another useful interactive option is --pager. respectively.com/tools/tool. and database. A complete list of special character sequences to use with --prompt can be found at http://dev. using --disable-tee only makes sense if you want to override a --tee option specified in an option file. similar to the “prompt” command on the interactive command line. and \d are special character sequences that refer to the host.php?id=126 shell>mysql -u root -prootpass --prompt="mysql [\h] {\u} (\d) > " Welcome to the MySQL monitor. Database changed mysql [localhost] {root} (mysql) > \h. the notee command is used: mysql> notee Outfile disabled.' or '\h' for help.com/doc/refman/5. The default is “mysql>”. Thus. username. Using --disable-tee still allows for the tee and notee commands to be run in the interactive client shell.html. This is similar to: mysql> tee name Logging to file 'name' To stop writing to the outfile while in the interactive client shell. Type '\c' to clear the buffer. Other Options Another option that is similar to a command on the interactive command line is --prompt=name. \u. Commands end with .0.mysql.Page 18 Summer 2008 MySQL mysql options continued from previous page Logging Output You may already know about the --tee and --disable-tee options. The equivalent option to mysql is --disable-tee will disable the outfile.

and which groups are applied: http://planetmysql. As you might expect. The --sigint-ignore option means that I can hit CTRL-C to my heart's content and not cause anything to happen. visit Planet MySQL at http://planetmysql. which is not the desired result. and I often hit CTRL-C after highlighting some text because I mean to copy it.' or '\h' for help.org mysql options continues on next page . You will have to test this on your own system. --help shows syntax and available options for your version of mysql.03 sec) mysql> Some folks find it annoying that MySQL will display an error. There are several new articles daily. or \g. otherwise known as CTRL-C. Type '\c' to clear the buffer. keystroke had no effect in an article.org to read the MySQL employee and community blogs. | Tables_in_information_schema | 16 rows in set (0.45-community-nt-log MySQL Community Edition (GPL) Type 'help. --sigint-ignore. | information_schema | 4 rows in set (0. You can set the --showwarnings option to automatically print warning statements just like error statements. Commands end with . For a complete listing of what your client can do. but in order to see a warning you Can’t Get Enough? have to type SHOW WARNINGS after noticing that a warning was generated. However. --help also notes the order in which the applicable option files are read. bloggers can submit feeds as well.02 sec) mysql> use information_schema Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables. This sends a “sigint” or “break” signal to the mysql server. as it is difficult to show that a If a quarterly dose of MySQL news and technical articles is not enough. CTRL-C means “copy” in many programs. mysql> show databases. use the --help option to mysql. This ignores the SIGINT command.Page 19 Summer 2008 MySQL mysql options continued from previous page shell> mysql -u root -prootpass --pager="grep info" Welcome to the MySQL monitor.0. I will end with one of my favorite options to the mysql command line client. Your MySQL connection id is 68 Server version: 5.

----------------------------auto-rehash TRUE character-sets-dir (No default value) default-character-set latin1 compress FALSE database (No default value) delimiter ..0 Copyright (C) 2002 MySQL AB This software comes with ABSOLUTELY NO WARRANTY. Cabral is a MySQL DBA for The Pythian Group. -I.. [more options deleted] ... [more default values deleted] . .. Sheeri K. This is free software. Default options are read from the following files in the given order: /etc/mysql/my. Inc...technocation. . she fills Technocation’s site with videos from conferences and user groups...16. In her spare time.cnf ~/.. --show-warnings Show warnings after every statement. Cabral won MySQL’s Community Advocate Award in 2007 and 2008.. ..12 Distrib 5.cnf The following groups are read: mysql client The last part of the output of --help is the default variable settings after the applicable configuration files and groups are read: Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------. .Page 20 Summer 2008 MySQL mysql options continued from previous page shell> mysql --help | more mysql Ver 14.. For all her volunteer work. for pc-linux-gnu (i386) using readline 5.0.my. blog postings. secure-auth FALSE show-warnings FALSE Hopefully this article has helped you be more productive using the command line mysql client.org). and you are welcome to modify and redistribute it under the GPL license Usage: mysql [OPTIONS] [database] -?. and occasionally podcasts. She founded Technocation. --help Display this help and exit. The views and opinions expressed in this article are the author’s own and may not reflect the views and opinions of The Pythian Group. a not-for-profit organization dedicated to providing free educational resources for IT professionals. (www.. About the author . . --help Synonym for -? ...

With the help of Mark Schoonover we developed thirty-four questions covering a range of subjects. In my log-bin column I manage to get in a few thoughts however. Because of space constraints I am not going to spend any time giving analyses of the results here.Page 21 Summer 2008 MySQL MySQL Magazine's 2008 Annual MySQL Usage Survey By Keith Murphy It has been my desire to do this survey for quite some time. There were over 400 responses to the survey with people chiming in from all over the world. Q1 Primary Job Function 180 160 159 140 120 100 80 60 59 48 60 40 Internet/Intranet/Extranet Management/Development/St rategy E-Business Management/Development/St rategy E-Commerce Management/Development/St rategy New Media Management/Strategy Webmaster/Web Development Other E-Business/Internet Management/Development/St rategy IS/MIS/DP Network Systems Data Communications/Telecommu nications Software/Applications Development/Programming Systems Engineering/Analysis/Integrati on/Technical Services Other 20 4 0 6 5 9 7 8 9 Survey continues on next page .

is opening a sales office in the United States. and MySQL. We have a complete review of the previous release in this very issue. Option to generate a SQL sync script was added.0.1) is a heterogeneous database monitoring/reporting tool currently supports Oracle. New features of this release include: · · · · · · New GRID design for easier navigation Multiple selection in GRIDs with SHIFT+CLICK. . Drastically improved the speed of exports. Now typically 2-8 times faster than before depending on data. dbWatch Software. July the 14th. saw the release of SQLyog 7.Page 22 Summer 2008 MySQL Survey continued from previous page Q2 What country do you live in ? 30 27 25 20 15 10 8 7 6 5 4 3 1 0 4 2 1 1 2 1 1 2 1 3 2 1 1 3 2 Brazil Australia Belgium Canada China Europe Finland France Germany India Italy Netherlands Peru Poland Romania Scotland Serbia Sweden UK USA Ukraine South America Survey continues on next page News This issue brings us a couple of announcements about major versions of software that can be used to support MySQL. Their product dbWatch (v8. SQL Server. one of our new advertisers. Monday. Improved Data Synchronization. Added automatic and manual update check In addition. New more user friendly design for the Schema Synchronization (renamed from Structure Synchronization).

Page 23 Summer 2008 MySQL Survey continued from previous page Q3 Is your position local or remote? 350 310 300 250 200 150 100 80 Local ( I work in an office ) Remote 50 0 Q4 Years of MySQL Experience 160 140 136 121 120 100 80 70 46 <= 2 60 40 20 19 0 3 <= 4 5 <= 7 8 <= 10 > 10 Survey continues on next page .

000-$64.999 $65.000-$54.999 $55.000-$69.999 $85.000-$79.000-$119.999 $90.000-$49.000 Survey continues on next page .000-$99.999 $75.999 $95.999 $35.999 $70.000 $20.999 $45.000-$59.999 $50.000-$109.000-$29.000-$39.000-$94.999 $80.999 $60.000-$74.000-$34.000-$84.000-$129.999 $120.999 $110.000-$89.Page 24 Summer 2008 MySQL Survey continued from previous page Q5 Salary 35 30 30 27 26 25 27 24 24 28 20 20 20 19 17 17 16 12 12 13 15 16 15 15 10 5 4 0 < $20.999 $30.999 $40.999 > $130.999 $100.000-$44.

Page 25 Summer 2008 MySQL Survey continued from previous page 300 Q6 Do you have additional duties? 272 250 214 200 150 108 100 50 26 0 System Administration Network Administration Programmer Other Survey continues on next page .

peripherals) Computer/Network Services/Consultant Computer Related Reailer/Wholesaler/Distributor Medical/Dental/Healthcare Transportation/Utilities 80 71 70 65 60 50 40 38 28 22 18 13 36 28 19 10 30 20 10 5 1 0 6 1 7 5 2 3 1 Survey continues on next page .Page 26 Summer 2008 MySQL Survey continued from previous page Q7 What is your organization's primary business activity? Online Retailer Internet Service Provider (ISP) or Application Service Provider (ASP) Communications Carrier Aerospace Banking/Finance/Accounting Insurance/Real Estate/Legal Federal Government (including military) State/Local Government Construction/Architecture/Engineering Data Processing Services Wholesale/Retail/Distribution Education Marketing/Advertising/Entertainment Research/Development Lab Business Services/Constultant Computer Manufacturer (Hardware. software.

x Base MySQL 4.x Professional Certified MySQL Associate (CMA) Certified MySQL Database Administrator (CMDBA) Certified MySQL Cluster Administrator (CMCDBA) Certified MySQL Developer (CMDEV) 200 150 100 50 30 17 11 8 7 0 Survey continues on next page .Page 27 Summer 2008 MySQL Survey continued from previous page Q8 Do you have any MySQL Certifications? 400 350 343 300 250 No MySQL 4.

how did you prepare for it? 80 70 67 60 50 40 30 20 10 10 2 0 3 5 Self Study Conference Tutorial MySQL Training Course Company Internal MySQL Training Course Other Survey continues on next page .Page 28 Summer 2008 MySQL Survey continued from previous page Q9 If you do have MySQL Certification.

Page 29 Summer 2008 MySQL Survey continued from previous page Q10 Which MySQL Certification are you planning on obtaining this year? 350 300 288 250 200 150 100 50 41 13 18 39 0 None Certified MySQL Associate (CMA) Certified MySQL Database Administrator (CMDBA) Certified MySQL Cluster Administrator (CMCDBA) Certified MySQL Developer (CMDEV) 180 Q11 What operating systems do you run MySQL on? 164 160 155 140 122 120 120 123 Ubuntu RedHat CentOS Slackware Debian Solaris SPARC Solaris Intel Windows 2000/2003 FreeBSD MAC OS/X Fedora Other 100 80 77 60 41 40 28 20 28 7 10 7 0 Survey continues on next page .

x 4.x 6.Page 30 Summer 2008 MySQL Survey continued from previous page Q12 What versions of MySQL do you use? (multiple choice) 350 313 300 250 206 200 164 150 100 50 22 0 16 MySQL MySQL MySQL MySQL MySQL 3.x 5.x 5.x 160 Q13 Do you work with other RDBS? (multiple choice) 140 137 120 106 101 100 99 80 60 No Oracle MSSQL Sybase PostgreSQL DB2 SQLlite Other 40 27 22 20 19 9 0 Survey continues on next page .1.0.

Page 31 Summer 2008 MySQL Survey continued from previous page Q14 Which MySQL high availability solution are you currently using? (multiple choice) 250 203 200 None MySQL MySQL MySQL MySQL with DRBD Simple Replication Complex Replication Cluster 153 150 100 55 50 31 26 0 400 Q15 Have you or your company outsourced DBA duties? 350 350 300 250 200 150 100 50 34 TRUE FALSE Survey continues on next page 0 .

Page 32 Summer 2008 MySQL Survey continued from previous page Q16 Have you or your company ever outsourced programming duties? 300 270 250 200 150 117 100 50 TRUE FALSE 0 400 Q17 Have you used the embedded version of MySQL (libmysqld)? 350 341 300 250 200 150 100 50 40 TRUE FALSE 0 Survey continues on next page .

x MySQL Connector/ODBC 5.2 MySQL Connector/ODBC 3.NET Visual Basic bash/csh/ksh/zsh Other 150 138 124 110 100 75 50 46 32 18 5 20 29 0 Survey continues on next page .x DBD::MySQL PHP PDO_MYSQLND Python DB-API 102 100 86 50 39 16 11 43 35 40 0 300 Q19 Which programming languages do you use?(multiple choice) 250 247 218 200 C/C++ C# Java Mono PHP Perl Ruby Python VB .Page 33 Summer 2008 MySQL Survey continued from previous page Q18 Which connectors do you use? (multiple choice) 250 200 197 150 133 None MySQL C API MySQL Connector/J MySQL Connector/NET 5.1 MySQL Connector/NET 5.

Page 34 Summer 2008 MySQL Survey continued from previous page Q20 Do you identify yourself as part of the community of MySQL users? 180 162 160 142 140 120 100 80 75 60 40 20 13 Yes Somewhat No Don't Care Q21 Do you use the MySQL Forge? 0 180 162 160 142 140 120 100 80 75 60 40 Yes Somewhat No Don't Care 20 13 0 Survey continues on next page .

Page 35 Summer 2008 MySQL Survey continued from previous page Q22 Have you reported MySQL bugs? 300 266 250 200 150 126 100 50 TRUE FALSE 0 400 Q23 Have you contributed to MySQL documentation? 357 350 300 250 200 150 100 50 33 TRUE FALSE 0 Survey continues on next page .

Once a week. 50 13 0 18 24 14 31 Survey continues on next page . Every other month. Too infrequent to remember.Page 36 Summer 2008 MySQL Survey continued from previous page Q24 Have you contributed code to MySQL? 400 367 350 300 250 200 150 100 50 22 0 TRUE FALSE 250 Q25 How often do you blog about MySQL? 215 200 150 100 82 Never Multiple times a week. Bimonthly Once a month.

com xaprb (Baron Schwartz) datacharmer (Giuseppe Maxia) krow (Brian Aker) Jay Pipes Pythian Jeremy Cole Sheeri Cabral Keith Murphy 100 77 44 19 14 10 9 8 7 7 Count Q27 With the recent discussion on oursql-sources mailing list regrading the MySQL Contributor License Agreement (CLA).planetmysql.mysqlperformance.Page 37 Summer 2008 MySQL Survey continued from previous page Q26 What is your favorite blog? Blog http://www.com http://www. should MySQL change the CLA to make it easier for the community to contribute code back to MySQL? 180 165 160 140 120 100 80 60 40 20 Yes No Don't Care 0 Survey continues on next page .

Page 38 Summer 2008 MySQL Survey continued from previous page Q28 Do you think the community edition of MySQL will fork if the current CLA remains unchanged? 180 160 154 140 120 117 110 100 80 60 40 20 Yes No Don't Care Q29 Which storage engines do you use? (multiple choice) 0 400 350 344 344 300 250 MyISAM InnoDB MERGE MEMORY (HEAP) BDB EXAMPLE FEDERATED ARCHIVE CSV BLACKHOLE FALCON 200 150 100 100 50 37 10 2 30 37 20 26 6 0 Survey continues on next page .

in production No. I haven't tried it I don't know what Federated is 50 19 0 Survey continues on next page . but I've tried it No.Page 39 Summer 2008 MySQL Survey continued from previous page Q30 The main reason for using Innodb? 250 200 192 150 100 78 78 50 33 Transaction support Row-level locking Foreign key support I don't use InnoDB Q31 Do you use Federated? 0 250 200 191 150 112 100 70 Yes.

Page 40 Summer 2008 MySQL Survey continued from previous page Q32 I don't use federated because: 250 212 200 150 100 50 35 24 8 0 I don't need it It doesn't have the features I need It's not stable enough It's not efficient 160 Q33 What is most important to you about MySQL server? 140 139 140 120 100 80 70 60 40 34 Performance Reliability Ease of Use Other 20 0 Survey continues on next page .

Page 41 Summer 2008 MySQL Survey continued from previous page Q34 Are you a current customer of Sun/MySQL? 350 301 300 250 200 150 100 89 50 0 TRUE FALSE .

We really could not have done it without his help.Page 42 Summer 2008 MySQL Log-bin The highlight of this issue. the natural thing to do is to have advertisers. I was surprised that over 25% of the respondents actually worked remotely. If you don't like that advertisements. I love working from my home. We have a very targeted market segment and while I know very little about marketing. There are plenty of questions to choose from for your own favorite! This issue marks the start of our second year. If you are really offended I suppose you don't have to read the magazine. Keith bmurphy@paragon-cs. I have had the idea to do a survey like this for quite some time. feel free to flip over them. However. I apologize for those. the choice to allow advertising is not one of those mistakes. I will be doing some advertising for the magazine at the next MySQL Users Conference by giving away t shirts since they seem to be so popular. I just saw a need and tried my best to fill it. To me it makes sense. the most interesting question was if a person worked remotely or "at the office".com . The money that is generated through advertising goes directly into supporting the magazine and paying the people who contribute to the magazine. These things cost money. There are companies willing to pay to advertise their product or service. I think that each issue has brought about improvements. I am sure I have made mistakes in this process. Having written a couple of articles myself I know it takes a lot of work. To me. There have never been a shortage of people who were willing to write articles. Being a MySQL DBA makes this a natural fit. It doesn't cost you anything so you aren't going to be out any money. I would like to take the time to publicly thank Mark Schoonover for his extensive help with the survey. As a database administrator myself I found the last item rather disconcerting. in my humble opinion. I do know that having a targeted market of a decent size is a good thing. While the reaction to this for the most part has been has been rather ho-hum. there have been some people who have expressed their opinion that this is a bad thing. I think for a first edition it went pretty well. I had no real expectations for the magazine when I started it. what companies actually use in production. So. Unlike many other database servers there can be a lack of information about usage patterns. Since I didn't manage to strike it rich in the "valley" during the late nineties I can't pay them from my pocket. or even the salary ranges of the database administrator. is the survey of MySQL Usage Survey. Thanks. While it certainly wasn't perfect.