1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Monday, May 14, 2012

10 essential performance tips for MySQL



http://www.computerworld.com/s/article/9227128/10_essential_performance_tips_for_MySQL?source=rss_latest_content&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+computerworld%2Fnews%2Ffeed+%28Latest+from+Computerworld%29&utm_content=Google+Feedfetcher
 - Computerworld

From workload profiling to the three rules of indexing, these expert insights are sure to make your MySQL servers scream

Baron Schwartz
May 14, 2012 (Infoworld)
As with all relational databases, MySQL can prove to be a complicated beast, one that can crawl to a halt at a moment's notice, leaving your applications in the lurch and your business on the line.
The truth is, common mistakes underlie most MySQL performance problems. To ensure your MySQL server hums along at top speed, providing stable and consistent performance, it is important to eliminate these mistakes, which are often obscured by some subtlety in your workload or a configuration trap.
[ To enhance the performance and health of your MySQL systems, check out our 10 essential MySQL tools for admins. | Learn how to master MySQL in the Amazon cloud. | Keep up to date on the key business tech news and insights with the InfoWorld Daily newsletter. Subscribe today! ]
Luckily, many MySQL performance issues turn out to have similar solutions, making troubleshooting and tuning MySQL a manageable task.
Here are 10 tips for getting great performance out of MySQL.
MySQL performance tip No. 1: Profile your workloadThe best way to understand how your server spends its time is to profile the server's workload. By profiling your workload, you can expose the most expensive queries for further tuning. Here, time is the most important metric because when you issue a query against the server, you care very little about anything except how quickly it completes.
The best way to profile your workload is with a tool such as MySQL Enterprise Monitor's query analyzer or the pt-query-digest from the Percona Toolkit. These tools capture queries the server executes and return a table of tasks sorted by decreasing order of response time, instantly bubbling up the most expensive and time-consuming tasks to the top so that you can see where to focus your efforts.
Workload-profiling tools group similar queries together into one row, allowing you to see the queries that are slow, as well as the queries that are fast but executed many times.
MySQL performance tip No. 2: Understand the four fundamental resourcesTo function, a database server needs four fundamental resources: CPU, memory, disk, and network. If any of these is weak, erratic, or overloaded, then the database server is very likely to perform poorly.
Understanding the fundamental resources is important in two particular areas: choosing hardware and troubleshooting problems.
When choosing hardware for MySQL, ensure good-performing components all around. Just as important, balance them reasonably well against each other. Often, organizations will select servers with fast CPUs and disks but that are starved for memory. In some cases, adding memory is cheap way of increasing performance by orders of magnitude, especially on workloads that are disk-bound. This might seem counterintuitive, but in many cases disks are overutilized because there isn't enough memory to hold the server's working set of data.
Another good example of this balance pertains to CPUs. In most cases, MySQL will perform well with fast CPUs because each query runs in a single thread and can't be parallelized across CPUs.
When it comes to troubleshooting, check the performance and utilization of all four resources, with a careful eye toward determining whether they are performing poorly or are simply being asked to do too much work. This knowledge can help solve problems quickly.
MySQL performance tip No. 3: Don't use MySQL as a queueQueues and queue-like access patterns can sneak into your application without your knowing it. For example, if you set the status of an item so that a particular worker process can claim it before acting on it, then you're unwittingly creating a queue. Marking emails as unsent, sending them, then marking them as sent is a common example.
Queues cause problems for two major reasons: They serialize your workload, preventing tasks from being done in parallel, and they often result in a table that contains work in process as well as historical data from jobs that were processed long ago. Both add latency to the application and load to MySQL.
MySQL performance tip No. 4: Filter results by cheapest firstA great way to optimize MySQL is to do cheap, imprecise work first, then the hard, precise work on the smaller, resulting set of data.
For example, suppose you're looking for something within a given radius of a geographical point. The first tool in many programmers' toolbox is the great-circle (Haversine) formula for computing distance along the surface of a sphere. The problem with this technique is that the formula requires a lot of trigonometric operations, which are very CPU-intensive. Great-circle calculations tend to run slowly and make the machine's CPU utilization skyrocket.
Before applying the great-circle formula, pare down your records to a small subset of the total, and trim the resulting set to a precise circle. A square that contains the circle (precisely or imprecisely) is an easy way to do this. That way, the world outside the square never gets hit with all those costly trig functions.
MySQL performance tip No. 5: Know the two scalability death trapsScalability is not as vague as you may believe. In fact, there are precise mathematical definitions of scalability that are expressed as equations. These equations highlight why systems don't scale as well as they should.
Take the Universal Scalability Law, a definition that is handy in expressing and quantifying a system's scalability characteristics. It explains scaling problems in terms of two fundamental costs: serialization and crosstalk.
Parallel processes that must halt for something serialized to take place are inherently limited in their scalability. Likewise, if the parallel processes need to chat with each other all the time to coordinate their work, they limit each other.
Avoid serialization and crosstalk, and your application will scale much better. What does this translate into inside of MySQL? It varies, but some examples would be avoiding exclusive locks on rows. Queues, point No. 3 above, tend to scale poorly for this reason.
MySQL performance tip No. 6: Don't focus too much on configurationDBAs tend to spend a huge amount of time tweaking configurations. The result is usually not a big improvement and can sometimes even be very damaging. I've seen a lot of "optimized" servers that crashed constantly, ran out of memory, and performed poorly when the workload got a little more intense.
The defaults that ship with MySQL are one-size-fits-none and badly outdated, but you don't need to configure everything. It's better to get the fundamentals right and change other settings only if needed. In most cases, you can get 95 percent of the server's peak performance by setting about 10 options correctly. The few situations where this doesn't apply are going to be edge cases unique to your circumstances.
In most cases, server "tuning" tools aren't recommended because they tend to give guidelines that don't make sense for specific cases. Some even have dangerous, inaccurate advice coded into them -- such as cache hit ratios and memory consumption formulas. These were never right, and they've gotten even less correct as time has passed.
MySQL performance tip No. 7: Watch out for pagination queriesApplications that paginate tend to bring the server to its knees. In showing you a page of results, with a link to go to the next page, these applications typically group and sort in ways that can't use indexes, and they employ a LIMIT and offset that causes the server to do a lot of work generating, then discarding rows.
Optimizations can often be found in the user interface itself. Instead of showing the exact number of pages in the results and links to each page individually, you can just show a link to the next page. You can also prevent people from going to pages too far from the first page.
On the query side, instead of using LIMIT with offset, you can select one more row than you need, and when the user clicks the "next page" link, you can designate that final row as the starting point for the next set of results. For example, if the user viewed a page with rows 101 through 120, you would select row 121 as well; to render the next page, you'd query the server for rows greater than or equal to 121, limit 21.
MySQL performance tip No. 8: Save statistics eagerly, alert reluctantlyMonitoring and alerting are essential, but what happens to the typical monitoring system? It starts sending false positives, and system administrators set up email filtering rules to stop the noise. Soon your monitoring system is completely useless.
I like to think about monitoring in two ways: capturing metrics and alerting. It's very important to capture and save all the metrics you possibly can because you'll be glad to have them when you're trying to figure out what changed in the system. Someday, a strange problem will crop up, and you'll love the ability to point to a graph and show a change in the server's workload.
By contrast, there's a tendency to alert way too much. People often alert on things like the buffer hit ratio or the number of temporary tables created per second. The problem is that there is no good threshold for such a ratio. The right threshold is not only different from server to server, but from hour to hour as your workload changes.
As a result, alert sparingly and only on conditions that indicate a definite, actionable problem. A low buffer hit ratio isn't actionable, nor does it indicate a real issue, but a server that doesn't respond to a connection attempt is an actual problem that needs to be solved.
MySQL performance tip No. 9: Learn the three rules of indexingIndexing is probably the most misunderstood topic in databases because there are so many ways to get confused about how indexes work and how the server uses them. It takes a lot of effort to really understand what's going on.
Indexes, when properly designed, serve three important purposes in a database server:
If you can design your indexes and queries to exploit these three opportunities, you can make your queries several orders of magnitude faster.
MySQL performance tip No. 10: Leverage the expertise of your peersDon't try to go it alone. If you're puzzling over a problem and doing what seems logical and sensible to you, that's great. This will work about 19 times out of 20. The other time, you'll go down a rabbit hole that will be very costly and time-consuming, precisely because the solution you're trying seems to make a lot of sense.
Build a network of MySQL-related resources -- and this goes beyond toolsets and troubleshooting guides. There are some extremely knowledgeable people lurking on mailing lists, forums, Q&A websites, and so on. Conferences, trade shows, and local user group events provide valuable opportunities for gaining insights and building relationships with peers who can help you in a pinch.
For those looking for tools to complement these tips, you can check out my MySQL configuration toolQuery Advisor tool, and Percona Monitoring Plugins. The configuration tool can help you generate a baseline my.cnf file for a new server that's superior to the sample files that ship with the server. The Query Advisor analyzes your SQL to help detect potentially bad patterns such as pagination queries (No. 7). Percona Monitoring is a set of monitoring and graphing plugins to help you save statistics eagerly and alert reluctantly (No. 8). All three are freely available.
Related articles
This story, "10 essential performance tips for MySQL," was originally published at InfoWorld.com. Follow the latest developments in data management at InfoWorld.com. For the latest developments in business technology news, follow InfoWorld.com on Twitter.
Read more about data management in InfoWorld's Data Management Channel.

Tuesday, July 6, 2010

MySQL Startup Failing/Hanging in Ubuntu 10.04

(I commented out the bind-address lines in /etc/mysql/my.cnf, HL 20100706 )

There is a bug in 10.04. If you have it bind to a specific interface, it will fail to start on reboot because it attempts to start after any network interface (such as 127.0.0.1) is initialized. The interface it was configured to bind with won't be initialized yet.
You can either bind it to all interfaces by commenting that line out, or edit /etc/init/mysql.conf.

start on (net-device-up IFACE=eth0
and local-filesystems)
stop on runlevel [016]


http://ubuntuforums.org/showthread.php?t=1475798
10. If the automatic startup still fails, you may follow the advice from a different thread: change the start condition in /etc/init/mysql.conf to "start on (net-device-up IFACE=ethX)", where "X" is the interface you have mysql bound to, e.g. ETH1.
11. In my case, I had another very specific problem: I'm running Ubuntu in a VM with several virtual disks which were not mounted yet when the network was up. Quite tricky to figure out. So I modified the start condition to "start on (net-device-up IFACE=eth1 and stopped mountall)", and now everything is fine.

Friday, November 20, 2009

Copy MySQL database from one server to another remote server

Copy MySQL database from one server to another remote server

by Vivek Gite · 22 comments

Usually you run mysqldump to create database copy:
$ mysqldump -u user -p db-name > db-name.out

Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out user@remote.box.com:/backup

Restore database at remote server (login over ssh):
$ mysql -u user -p db-name < db-name.out

How do I copy a MySQL database from one computer/server to another?

Short answer is you can copy database from one computer/server to another using ssh or mysql client.

You can run all the above 3 commands in one pass using mysqldump and mysql commands (insecure method, use only if you are using VPN or trust your network):
$ mysqldump db-name | mysql -h remote.box.com db-name

Use ssh if you don't have direct access to remote mysql server (secure method):
$ mysqldump db-name | ssh user@remote.box.com mysql db-name

You can just copy table called foo to remote database (and remote mysql server remote.box.com) called bar using same syntax:
$ mysqldump db-name foo | ssh user@remote.box.com mysql bar

This will not just save your time but you can impress your friend too ;). Almost all commands can be run using pipes under UNIX/Linux oses.

Sunday, November 1, 2009

Drop all tables in a MySQL database

Drop all tables in a MySQL database

After finding a reference on the MySQL Lists (http://lists.mysql.com/mysql/193430) I started playing with the idea. I didn't want to have to dump into one file and then run that query. Also - the problem with the above concept is that it drops the table and then recreates it - not what i wanted!

I then looked into using the pipe and grep features in Linux. Now I was getting somewhere! A few tweaks later and this is what I got:

  1. mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]

In the above, [USERNAME], [PASSWORD] & [DATABASE] are all the details for your database. You might not need the username and password fields - depends on your setup!

Wednesday, October 21, 2009

How to Install Zen Cart on a LAMP server

How to: Install Zen Cart on a LAMP server

(Note: I first installed through Godaddy's Connection but found automatically created MySQL database can't be accessed remotely. Then I am trying to install manually. HL )

If you have ever had a need for an on-line shopping cart, and have ever tried to install a shopping cart, you know that making a choice can be a challenge, and getting the shop up and running can be a challenge.

Not so much with Zen Cart. Zen Cart is an open source e-commerce solution that serves as a stand-alone shopping cart and is installed on top of a LAMP server. If you're not sure how to install a LAMP server check out my article "How to: Install a LAMP server." With that LAMP server up and running you are ready to install Zen Cart.

The installation of Zen Cart will require you to use a few Linux commands: zip, mv, and chmod. But that is it. For the purposes of this article I will assume you are using phpmyadmin for the database creation. If you need help installing phpmyadmin check out my article "Install phpmyadmin for easy MySQL administration."

With all of that in mind, let's begin the installation.

Getting Zen Cart

The first thing you need to do is download Zen Cart. But don't just open your browser to the download page. Instead ssh to the server that will house Zen Cart, cd to the server document root, and use wget to download the necessary file into the correct directory. The command to download Zen Cart is:

sudo wget "http://downloads.sourceforge.net/project/zencart/CURRENT_ Zen Cart 1.3.x Series/Zen Cart v1.3.8 - Full Release/zen-cart-v1.3.8a-full-fileset-12112007.zip"

NOTE: Since there are space in the path name you do have to make use of the "" when using wget to download the file.

With the file downloaded and in place it is time to unzip the file. To unzip the Zen Cart file issue this command:

sudo unzip zen-cart-v1.3.8a-full-fileset-12112007.zip

which will create the directory zen-cart-v1.3.8a-full-fileset-12112007. To make your life easier you will want to change the name of that directory to a much easier name. This directory is what you (and your customers) will use to access your shopping cart, so make it easy. I rename mine zencart or shopping. Rename this to suit your needs. Rename it with the command:

sudo mv zen-cart-v1.3.8a-full-fileset-12112007 zencart

Now it's time to create the configuration file and make some changes to permissions.

Configuration files and permissions

Zen Cart does not unpack with the necessary configuration files in place. What you have to do is rename to files so they will serve as your configuration files. To do this issue the following commands (from within your Zen Cart directory):

sudo mv includes/dist-configure.php includes/configure.php

and

sudo mv admin/includes/dist-configure.php admin/includes/configure.php

The next step is to change the permissions of the configuration files like so:

sudo chmod 777 includes/configure.php

and

sudo chmod 777 admin/includes/configure.php

The configuration files are set. Time to change permissions of some directories.

Below are all of the commands you need to run to set the correct permissions for your installation:

sudo chmod 777 cache
sudo chmod 777 includes/languages/english/html_includes
sudo chmod 777 media
sudo chmod 777 pub
sudo chmod 777 admin/backups
sudo chmod 777 admin/images/graphs

With this complete you are now ready to create your database and log into the web-based installer and install Zen Cart.

Installing via web

After you create your database (using phpmyadmin) log into the Zen Cart install like so:

http://IP_TO_SERVER/ZENCART/zc_install

Where IP_TO_SERVER is the actual IP address of your server and ZENCART is the name you have given your Zen Cart directory.

The web-based installation is very simple. You will only have to insert options like the MySQL user and password, name of site, administrator name/email, etc. Outside of some very easy questions, Zen Cart will most likely correctly guess all of the details of your installation.

After you have stepped through the installation wizard your Zen Cart installation is done. You will be directed to either immediately administer the site or view the site.

Final thoughts

Zen Cart is one of the better shopping cart systems available from the open source community. It is easy to install/administer, robust, feature-rich, and reliable. If you have a need for ecommerce make sure you check out Zen Cart first.

MySQL and UTF-8

MySQL and UTF-8 [Web Application Component Toolkit]

Good support from 4.1

utf-8 is utf8 in MySQL.

A collation defines the sort order for the data, it may be case sensitive or not

To find out your current setup:

SHOW VARIABLES LIKE 'character_set_database';  SHOW VARIABLES LIKE 'character_set_client'; 

To see available character sets and collations on your database:

SHOW CHARACTER SET;  SHOW COLLATION LIKE 'utf8%'; 

Character set and collation can be set per server, database, table, connection;

Server (/etc/my.cnf):

[mysqld]  ...
default-character-set=utf8
default-collation=utf8_general_ci

Database:

(CREATE | ALTER) DATABASE ... DEFAULT CHARACTER SET utf8 

Table:

(CREATE | ALTER) TABLE ... DEFAULT CHARACTER SET utf8 

Connection:

SET NAMES 'utf8'; 

A PHP mysql connection (not totally confirmed, but see tests below) defaults to a latin1 connection, so, your first query after connection should be:

mysql_query("SET NAMES 'utf8'"); 

In php versions 5.2 and later, use

mysql_set_charset('utf8',$conn);  

The CONVERT() function can convert between charsets, eg:

INSERT INTO utf8table (utf8column)  SELECT CONVERT(latin1field USING utf8) FROM latin1table;  

As mentioned in charsets, field widths may need to be increased to deal with multi-byte characters.

Code to generate a mass change of collations:

<?php   // this script will output the queries need to change all fields/tables to a different collation // it is HIGHLY suggested you take a MySQL dump prior to running any of the generated // this code is provided as is and without any warranty   die("Make a backup of your MySQL database then remove this line");   set_time_limit(0);   // collation you want to change: $convert_from = 'latin1_swedish_ci';   // collation you want to change it to: $convert_to   = 'utf8_general_ci';   // character set of new collation: $character_set= 'utf8';   $show_alter_table = true; $show_alter_field = true;   // DB login information $username = 'user'; $password = 'pass'; $database = 'table'; $host     = 'localhost';   mysql_connect($host, $username, $password); mysql_select_db($database);   $rs_tables = mysql_query(" SHOW TABLES ") or die(mysql_error());   print '<pre>'; while ($row_tables = mysql_fetch_row($rs_tables)) {     $table = mysql_real_escape_string($row_tables[0]);          // Alter table collation     // ALTER TABLE `account` DEFAULT CHARACTER SET utf8     if ($show_alter_table) {         echo("ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\r\n");     }       $rs = mysql_query(" SHOW FULL FIELDS FROM `$table` ") or die(mysql_error());     while ($row=mysql_fetch_assoc($rs)) {                  if ($row['Collation']!=$convert_from)             continue;           // Is the field allowed to be null?         if ($row['Null']=='YES') {             $nullable = ' NULL ';         } else {             $nullable = ' NOT NULL';         }           // Does the field default to null, a string, or nothing?         if ($row['Default']==NULL) {             $default = " DEFAULT NULL";         } else if ($row['Default']!='') {             $default = " DEFAULT '".mysql_real_escape_string($row['Default'])."'";         } else {             $default = '';         }           // Alter field collation:         // ALTER TABLE `account` CHANGE `email` `email` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL         if ($show_alter_field) {             $field = mysql_real_escape_string($row['Field']);             echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default; \r\n";         }     } }   ?>

MySQL tables, columns and connections with UTF-8

What happens when you INSERT a UTF-8 string into a MySQL database using PHP's MySQL extension? Well that depends on what string you use. If you use something like "Iñtërnâtiônàlizætiøn" then doing just about anything in MySQL will be data-safe (but, of course, the collation will be incorrect). If you have characters that don't encode the same in UTF-8 and latin1 (e.g. text in Chinese, Russian, ...) then the behaviour depends on both the table definition and the encoding of the connection to the database.


Table or column charset

latin1 (MySQL default) utf8
default connection mysql_pconnect() data is binary-safe but not encoded properly* data is binary-safe but not encoded properly*
using SET NAMES 'utf8'; data destroyed; string is converted to "????" works fine!

* It seems that MySQL will look at the data as being a series of bytes all within the latin1 codepage. If you use the same code to read and write the data then it will round-trip fine (but MySQL's collation will obviously be wrong). If you use tools with a knowledge of the data types used by MySQL, like phpMyAdmin or even mysql_dump, then the wrong encoding is obvious.

(this test was performed with PHP versions 4.4.2 and 5.1.2 and MySQL 5.0.20; PHP source for test)

Further Reading

How to Enable Remote Access To MySQL Database Server

How Do I Enable Remote Access To MySQL Database Server?

By default, MySQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home or from web server.

MySQL Remote Access

You need type the following commands which will allow remote connections:

Step # 1: Login over ssh if server is outside your IDC

First, login over ssh to remote MySQL database server

Step # 2: Enable networking

Once connected you need edit the mysql configuration file my.cfg using text editor such as vi.

  • If you are using Debian Linux file is located at /etc/mysql/my.cnf location
  • If you are using Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
  • If you are using FreeBSD you need to create a file /var/db/mysql/my.cnf

# vi /etc/my.cnf

Step # 3: Once file opened, locate line that read as follows

[mysqld] 

Make sure line skip-networking is commented (or remove line) and add following line

bind-address=YOUR-SERVER-IP

For example, if your MySQL server IP is 65.55.55.2 then entire block should be look like as follows:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 65.55.55.2
# skip-networking
....
..
....
Where,

  • bind-address : IP address to bind to.
  • skip-networking : Don't listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.

Step# 4 Save and Close the file

Restart your mysql service to take change in effect:# /etc/init.d/mysql restart

Step # 5 Grant access to remote IP address

# mysql -u root -p mysqlGrant access to new database
If you want to add new database called foo for user bar and remote IP 202.54.10.20 then you need to type following commands at mysql> prompt:mysql> CREATE DATABASE foo;
mysql> GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';

How Do I Grant access to existing database?

Let us assume that you are always making connection from remote IP called 202.54.10.20 for database called webdb for user webadmin, To grant access to this IP address type the following command At mysql> prompt for existing database:mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';

Step # 5: Logout of MySQL

Type exit command to logout mysql:mysql> exit

Step # 6: Open port 3306

You need to open port 3306 using iptables or BSD pf firewall.

A sample iptables rule to open Linux iptables firewall

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

OR only allow remote connection from your web server located at 10.5.1.3:

/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

OR only allow remote connection from your lan subnet 192.168.1.0/24:

/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT

A sample FreeBSD / OpenBSD pf rule ( /etc/pf.conf)

pass in on $ext_if proto tcp from any to any port 3306

OR allow only access from your web server located at 10.5.1.3:

pass in on $ext_if proto tcp from 10.5.1.3 to any port 3306  flags S/SA synproxy state

Step # 7: Test it

From remote system or your desktop type the command:
$ mysql -u webadmin –h 65.55.55.2 –p
Where,

  • -u webadmin: webadmin is MySQL username
  • -h IP or hostname: 65.55.55.2 is MySQL server IP address or hostname (FQDN)
  • -p : Prompt for password

You can also use telnet to connect to port 3306 for testing purpose:$ telnet 65.55.55.2 3306

MySQL Connector for OpenOffice.org 1.0

MySQL Connector for OpenOffice.org 1.0 - OpenOffice.org Wiki

(Note: I tried UnixODBC first but found utf-8 problem. Then I selected this way, so far so good. HL)

MySQL Connector for OpenOffice.org is a MySQL driver for OpenOffice.org. It can be used to connect from OpenOffice.org 3.1 to a MySQL server 5.1 or newer.

Before MySQL Connector for OpenOffice.org became available you'd have to use MySQL Connector/J (JDBC) or MySQL Connector for ODBC to connect to a MySQL server.

Therefore the driver is also referred to as a native driver in the context of OpenOffice.org. The term native driver clashes with the MySQL definition of a native driver: MySQL Connector for OpenOffice.org does not implement the MySQL Client Server protocol. Technically speaking the MySQL Connector for OpenOffice.org is implemented as a proxy on top of the MySQL Connector/C++.

The driver is delivered as an OpenOffice.org extension.

Advantages

Using MySQL Connector for OpenOffice.org has the following advantages:

  • Easy installation through the OpenOffice.org Extension Manager.
  • Seamless integration into OpenOffice.org.
  • Work on multiple MySQL schemata (databases) simultaneously
  • Connect to MySQL servers using named pipes (Windows) or Sockets (Unix)
  • No need to go through an additional Connector installation routine (ODBC/JDBC)
  • No need to configure or register an additional Connector (ODBC)
  • No need to install or configure a driver manager (ODBC)
  • No need for a Java Runtime Environment (JDBC)

Status

The MySQL Connector for OpenOffice.org is released in version 1.0, in production quality.

Tuesday, October 20, 2009

在Ubuntu下为MySQL添加ODBC驱动

在Ubuntu下为MySQL添加ODBC驱动_本本西祠2007
2009年04月15日 星期三 下午 06:06

学过Web开发的人应该都知道ODBC,这个微软自创的数据库连接方法使得在Windows下让程序连接数据库非常容易,比如Java的ODBC连 接MSSQL、Access等等。如果要开发一个跨平台跨数据库的程序,ODBC连接数据库就是一个不错的选择,只是在Linux并不像在Windows 下一样创建ODBC连接那么容易。这篇文章就是准备讲如何在Ubuntu下为MySQL添加ODBC驱动,使得在Ubuntu下也能使用ODBC连接数据 库。

让Ubuntu也可以创建ODBC连接是依靠一个开源项目叫做iODBC实现的,这个iODBC就是为了让Unix体系的系统也能使用ODBC连接,iODBC就是ODBC的开源实现。经过测试在Ubuntu 8.04和Ubuntu 8.10下均可正常工作。

首先要有MySQL,如果还未安装,一句话安装命令:

$sudo apt-get install mysql-client mysql-server

安装iODBC的驱动管理器(GTK编写的前端界面):

$sudo apt-get install iodbc

安装MySQL的ODCB连接器:

$sudo apt-get install libmydobc

启动iODBC:

$sudo iodbcadm-gtk

iODBC DSA

看 到这个界面应该感到很熟悉了吧,几乎和Windows下的ODBC连接设置界面一模一样。要给通过ODBC连接MySQL,就要加载MySQL的ODBC 驱动,单击"ODBC Drivers"标签卡,之后单击"Add a driver"按钮,在"ODBC Driver Add/Setup"对话框中依次设置如下内容:

Description of the driver:MySQL(可以随意起一个名字)
Driver file name:/usr/lib/odbc/libmyodbc.so
Setup file name:/usr/lib/odbc/libodbcmyS.so

如下图所示:

ODBC Driver Add/Setup

设 置完毕后单击"OK"按钮,即可加载MySQL的ODBC驱动,接下来就可以创建针对MySQL的ODBC连接了,单击"User DSN"或"System DSN"标签卡来单击"Add"按钮创建ODCB连接,在"Choose an ODBC Driver"对话框中可以看到刚刚添加的MySQL的ODBC驱动,选择之兵单击"Finish"按钮,将会弹出"Setup of DSN Unknown"对话框,需要设置的有"数据源名"(Data Source Name,DSN)和一些参数。数据源名通常由用户自行定义(比如"mysqldb"),参数对于MySQL的标准而言通常需要设定以下参数:

server
database
user
password

如下图所示来设置连接参数:

Setup of DSN Unknown

更多参数具体可以参考MySQL官方的连接参数资料。 设置完成之后单击『OK』按钮之后单击『Test』按钮,询问用户名和密码的对话框弹出之后输入MySQL的用户名和密码,返回"The connection DSN wastested successfully,and can be used at this time"即是设置成功。

现在就可以在Ubuntu下使用各种语言通过ODCB来连接MySQL了。

Monday, October 19, 2009

NoSQL: Distributed and Scalable Non-Relational Database Systems

NoSQL: Distributed and Scalable Non-Relational Database Systems | Linux Magazine

Non-SQL oriented distributed databases are all the rage in some circles. They're designed to scale from day 1 and offer reliability in the face of failures.

There's an interesting shift happening in the world of Web-scale data stores. A whole new breed of scalable data stores is gaining popularity very quickly. The traditional LAMP stack is starting to look like a thing of the past. For a few years now, memcached has often appeared right next to MySQL, and now the whole "data tier" is being shaken up.

While some might see it as a move away from MySQL and PostgreSQL, the traditional open source relational data stores, it's actually a higher-level change. Much of this is change is the result of a few revelations:

  1. a relational database isn't always the model or system for every piece of data
  2. relational databases are tricky to scale (especially if you start with a single monolithic configuration–they aren't distributed by design)
  3. normalization often hurts performance
  4. in many applications, primary key look-ups are all you need

The new data stores vary quite a bit in their specific features, but in general they draw from a similar set of high-level characteristics. Not all of them meet all of these, of course, but just looking at the list gives you a sense of what they're trying to accomplish.

  1. de-normalized, often schema-free, document storage
  2. key/value based, supporting lookups by key
  3. horizontal scaling
  4. built in replication
  5. HTTP/REST or easy to program APIs
  6. support for MapReduce style programming
  7. Eventually Consistent

And I could probably list another half a dozen qualities that many of them share too. But to me, the first two are the biggest departure form the traditional RDBMS. Of course, you can stick with MySQL and go non-relational. That's basically what FriendFeed did, using MySQL as the back-end to distributed key/value store.

The movement to these distributed schema-free data stores has begun to use the name NoSQL. Rather than spending a lot of time on the philosophy behind NoSQL storage systems, I'd rather highlight a few that have caught my eye for one reason or another and spend a bit of time talking about makes each stand out.

Redis

I'm not going to say too much about Redis, since I recently covered it in Redis: Lightweight key/value Store That Goes the Extra Mile. I'll just recap by saying that it's a lightweight in-memory key/value store that handles strings, sets, and lists and has an excellent core of features for manipulating those stored data types. Redis also has built-in replication support and the ability to periodically persist the data on disk so that can survive a reboot without major data loss. Redis is still one of the newer kids on the block but version 1.0 was released a few days after I last wrote about it–Murphy's Law, huh?

Redis is interesting to me because of the simplicity of its API and the fact that it takes the traditional key/value store up a notch by adding those specific data structures and provides fast atomic operations on them.

Tokyo Cabinet

Coming straight from Japan, Tokyo Cabinet is a fast and mature disk-based key/value store that feels a lot like BerkeleyDB re-written for the Web era. It is usually paired with Tokyo Tyrant, the network server that turns Tokyo Cabinet into a network service that speaks HTTP and the memcached protocol, as well as its own binary protocol.

Like the other modern DBM implementations, Tokyo Cabinet offers B-Tree, Hash, and fixed-size array-like record storage options. It stands out for me because, when used with Tokyo Tyrant, you have a modern network protocol and interface on top a stable low-level database infrastructure that lets you choose the right data structure to use. It is also relatively mature technology that's in use as part of some very high-volume Web sites.

Apache CouchDB

To quote the Apache CouchDB home page:

Apache CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript. CouchDB also offers incremental replication with bi-directional conflict detection and resolution.

CouchDB provides a RESTful JSON API than can be accessed from any environment that allows HTTP requests. There are myriad third-party client libraries that make this even easier from your programming language of choice. CouchDB's built in Web administration console speaks directly to the database using HTTP requests issued from your browser.

CouchDB is written in Erlang, a robust functional programming language ideal for building concurrent distributed systems. Erlang allows for a flexible design that is easily scalable and readily extensible.

In other words, CouchDB is very buzzword compliant!

Seriously, though, CouchDB was one of the first document oriented databases really designed for the Web and to scale with the Web. The fact that it's now under the unbrella of the Apache Software Foundation speaks to the quality of the code and the relative maturity of the project.

CouchDB appeals to me because it has always seemed to be the most futuristic of the non-relational data stores I've looked at. It's written in a language designed for large, concurrent, and reliable network systems. But it also gives you the ability to tap into Map/Reduce style processing using server-side JavaScript. It sounds a little crazy (or did when it first began), but it actually works quite well. The API is simple and well thought out, which provides a very low barrier to entry too. It's also easy to have a CouchDB instance on your desktop or laptop that you can develop with and then sync to a CouchDB server in "the cloud" or in your company's data center.

CouchDB also implements a very useful versioning scheme that makes it possible to build collaborative systems without having to re-invent yet another wheel.

Riak

The newest data store on my radar, Riak bills itself as a "document oriented web database" that "combines a decentralized key-value store, a flexible map/reduce engine, and a friendly HTTP/JSON query interface to provide a database ideally suited for Web applications." It uses the eventual consistency model in an effort to maximize availability in times of network or server outages. In fact, one of the most interesting features of Riak is that you can easily control the parameters that define how available your system is in the face of problems.

Those parameters come from Eric Brewer's CAP theorem (a good read) which says that the three ingredients we should care about are varying degrees of Consistency, Availability, and Partition Tolerance. Riak, unlike other systems, doesn't force you into a specific set of CAP values. Instead, it allows you to decide on a per-request basis how stringent you'd like to be.

This control comes thanks to three variables: N, R, and W. In a distributed system, N is the number of replicas in the system. So if you write a new key/value pair with N set to 4, then 4 nodes will be expected receive a copy of it (eventually). This value is set on a per-bucket basis.

The R and W values are set on a per-request basis and control the number of nodes that the client must receive a response from to complete a successful read or write operation, R fo read and W for write. This provides very granular control over how clients can react to failed nodes in a cluster.

For good high-level overview, see this presentation from the recent NoSQL Conference in New York City.

Others

There are a surprising number of NoSQL systems available today. The ones I've noted so far have caught my eye in one way or another and each uses a different approach to providing an alternative to centralized relational database systems. There are a few others that I'm hoping to experiment with as time allows.

  • MongoDB is a VC-backed distributed schema-free database with a very impressive feature set (including additional indexes), commercial support, and mosty hands-off operation.
  • Project Voldemort is a fairly mature system that's in heavy use at LinkedIn and comes with automatic replication and partitioning.
  • MemcacheDB combines the proven BerkeleyDB storage system with a network server that speaks the memcached network protocol so you can create memcahed-like nodes that hold more data than would fit in a traditional RAM-based memcached nodes and be assured that the data is not lost after a reboot. In some respects this is similar to the Tokyo Cabinet and Tokyo Tyrant combination.

Have you dipped your toe in the NoSQL waters yet? How did it go?

Jeremy Zawodny is a software engineer at Craigslist where he works on MySQL, Search, and various back-end infrastructure. He's also the co-author of "High Performance MySQL" and blogs at http://jeremy.zawodny.com/blog/

Sunday, October 18, 2009

Save MySQL query results into a text or CSV file

Save MySQL query results into a text or CSV file | MySQL | Tech-Recipes

Given a query such as

SELECT order_id,product_name,qty FROM orders

which returns three columns of data, the results can be placed into the file /tmo/orders.txt using the query:

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.txt'

This will create a tab-separated file, each row on its own line. To alter this behavior, it is possible to add modifiers to the query:

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

In this example, each field will be enclosed in "double quotes," the fields will be separated by commas, and each row will be output on a new line separated by a newline (\n). Sample output of this command would look like:

"1","Tech-Recipes sock puppet","14.95"
"2","Tech-Recipes chef's hat","18.95"
...

Keep in mind that the output file must not already exist and that the user MySQL is running as has write permissions to the directory MySQL is attempting to write the file to.

Tuesday, July 21, 2009

国产MYSQL数据库开源备份利器—帝国备份王

占奇博客
作者:admin 发表时间:07月 - 21 - 2009 5 views

写博客的同学都知道,MYSQL数据库备份这项工作既十分麻烦但又非常重要。麻烦的是要在phpmyadmin上点击一大堆按钮。重要的是保证在你的主机提供商跑路的那一天,你手里还一分数据库备份。但是用phpmyadmin备份数据通常有下面几个缺点:
1、如果你的MYSQL数据库太大了,phpmyadmin将很难导出你的数据库;
2、备份的数据重新导入新的数据库后通常会出现编码乱码问题;
3、不同MYSQL版本数据不能互导问题,万一你的新空间和你的老空间MYSQL版本不同的话,你可能会很麻烦了。

然而这个三个大问题,都让国产的开源软件——帝国备份王给完美解决了,废话少说,下面教大家怎么在你的空间上安装《帝国备份王》:

第1步:上传程序包
点击这里下载帝国备份王安装包,解压。在你的空间的根目录建立一个backup文件夹。将安装包的 upload 目录中的"全部文件和目录"全部上传到backup文件夹。

第2步:设置服务器777属性
设置目录属性您在正式使用以前,需要设置相关的目录属性,以便数据文件可以被《帝国备份王》正确的读写。使用 FTP 软件登录您的服务器,将服务器backup文件夹里的以下文件或目录属性设置为 777,见下:
目录文件名称
说明
bdata 备份目录
bdata/safemod 安全模式下数据备份目录
class/config.php 配置文件
setsave 保存设置目录
setsave/def 默认备份设置文件
zip 压缩包存放目录
tmp 临时文件目录

第3步:登陆后台
在浏览器中访问 http://您的域名/backup/index.php,就可以安装成功并可以立即访问后台了。
(后台默认的管理员帐号与密码分别为:admin , 123456)
登陆后自己修改帐号密码与数据库设置即可完成安装。

错误纠正:安装的过程中,如果你的空间没有开启"short-tag"支持的话,会出错,请开启这个服务。

后台使用说明
登录后台后即可轻松使用轻松备份和恢复数据
1.备份数据:备份数据 -> 选择备份的数据库 -> 选择备份的表与设定备份参数 -> 备份完毕
2.恢复数据:恢复数据 -> 选择恢复源目录,数据库 -> 恢复完毕
3.下载备份文件:下载备份目录下相应的备份目录即可。默认的备份目录为"bdata"。(对于文件少的也可直接到"管理备份目录"打包下载)

相关信息和演示
帝国备份王官方网站:http://www.phome.net/
本人安装成功的帝国备份王:http://zhanqi.s202.xrea.com/backup/index.php

Thursday, July 16, 2009

MySQL Commands

Posted on 07-25-2007 00:13:00 UTC | Updated on 01-23-2009 16:29:23 UTC
Section: /software/mysql/ | Permanent Link

This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');



MYSQL Statements and clauses

ALTER DATABASE ALTER TABLE ALTER VIEW ANALYZE TABLE BACKUP TABLE CACHE INDEX CHANGE MASTER TO CHECK TABLE CHECKSUM TABLE COMMIT CREATE DATABASE CREATE INDEX CREATE TABLE CREATE VIEW DELETE DESCRIBE DO DROP DATABASE DROP INDEX DROP TABLE DROP USER DROP VIEW EXPLAIN FLUSH GRANT HANDLER INSERT JOIN KILL LOAD DATA FROM MASTER LOAD DATA INFILE LOAD INDEX INTO CACHE LOAD TABLE...FROM MASTER LOCK TABLES OPTIMIZE TABLE PURGE MASTER LOGS RENAME TABLE REPAIR TABLE REPLACE RESET RESET MASTER RESET SLAVE RESTORE TABLE REVOKE ROLLBACK ROLLBACK TO SAVEPOINT SAVEPOINT SELECT SET SET PASSWORD SET SQL_LOG_BIN SET TRANSACTION SHOW BINLOG EVENTS SHOW CHARACTER SET SHOW COLLATION SHOW COLUMNS SHOW CREATE DATABASE SHOW CREATE TABLE SHOW CREATE VIEW SHOW DATABASES SHOW ENGINES SHOW ERRORS SHOW GRANTS SHOW INDEX SHOW INNODB STATUS SHOW LOGS SHOW MASTER LOGS SHOW MASTER STATUS SHOW PRIVILEGES SHOW PROCESSLIST SHOW SLAVE HOSTS SHOW SLAVE STATUS SHOW STATUS SHOW TABLE STATUS SHOW TABLES SHOW VARIABLES SHOW WARNINGS START SLAVE START TRANSACTION STOP SLAVE TRUNCATE TABLE UNION UNLOCK TABLES USE

String Functions

AES_DECRYPT AES_ENCRYPT ASCII BIN BINARY BIT_LENGTH CHAR CHAR_LENGTH CHARACTER_LENGTH COMPRESS CONCAT CONCAT_WS CONV DECODE DES_DECRYPT DES_ENCRYPT ELT ENCODE ENCRYPT EXPORT_SET FIELD FIND_IN_SET HEX INET_ATON INET_NTOA INSERT INSTR LCASE LEFT LENGTH LOAD_FILE LOCATE LOWER LPAD LTRIM MAKE_SET MATCH AGAINST MD5 MID OCT OCTET_LENGTH OLD_PASSWORD ORD PASSWORD POSITION QUOTE REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SHA SHA1 SOUNDEX SPACE STRCMP SUBSTRING SUBSTRING_INDEX TRIM UCASE UNCOMPRESS UNCOMPRESSED_LENGTH UNHEX UPPER

Date and Time Functions

ADDDATE ADDTIME CONVERT_TZ CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATE_ADD DATE_FORMAT DATE_SUB DATEDIFF DAY DAYNAME DAYOFMONTH DAYOFWEEK DAYOFYEAR EXTRACT FROM_DAYS FROM_UNIXTIME GET_FORMAT HOUR LAST_DAY LOCALTIME LOCALTIMESTAMP MAKEDATE MAKETIME MICROSECOND MINUTE MONTH MONTHNAME NOW PERIOD_ADD PERIOD_DIFF QUARTER SEC_TO_TIME SECOND STR_TO_DATE SUBDATE SUBTIME SYSDATE TIME TIMEDIFF TIMESTAMP TIMESTAMPDIFF TIMESTAMPADD TIME_FORMAT TIME_TO_SEC TO_DAYS UNIX_TIMESTAMP UTC_DATE UTC_TIME UTC_TIMESTAMP WEEK WEEKDAY WEEKOFYEAR YEAR YEARWEEK

Mathematical and Aggregate Functions

ABS ACOS ASIN ATAN ATAN2 AVG BIT_AND BIT_OR BIT_XOR CEIL CEILING COS COT COUNT CRC32 DEGREES EXP FLOOR FORMAT GREATEST GROUP_CONCAT LEAST LN LOG LOG2 LOG10 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT STD STDDEV SUM TAN TRUNCATE VARIANCE

Flow Control Functions

CASE IF IFNULL NULLIF

Command-Line Utilities

comp_err isamchk make_binary_distribution msql2mysql my_print_defaults myisamchk myisamlog myisampack mysqlaccess mysqladmin mysqlbinlog mysqlbug mysqlcheck mysqldump mysqldumpslow mysqlhotcopy mysqlimport mysqlshow perror

Perl API - using functions and methods built into the Perl DBI with MySQL

available_drivers begin_work bind_col bind_columns bind_param bind_param_array bind_param_inout can clone column_info commit connect connect_cached data_sources disconnect do dump_results err errstr execute execute_array execute_for_fetch fetch fetchall_arrayref fetchall_hashref fetchrow_array fetchrow_arrayref fetchrow_hashref finish foreign_key_info func get_info installed_versions last_insert_id looks_like_number neat neat_list parse_dsn parse_trace_flag parse_trace_flags ping prepare prepare_cached primary_key primary_key_info quote quote_identifier rollback rows selectall_arrayref selectall_hashref selectcol_arrayref selectrow_array selectrow_arrayref selectrow_hashref set_err state table_info table_info_all tables trace trace_msg type_info type_info_all Attributes for Handles

PHP API - using functions built into PHP with MySQL

mysql_affected_rows mysql_change_user mysql_client_encoding mysql_close mysql_connect mysql_create_db mysql_data_seek mysql_db_name mysql_db_query mysql_drop_db mysql_errno mysql_error mysql_escape_string mysql_fetch_array mysql_fetch_assoc mysql_fetch_field mysql_fetch_lengths mysql_fetch_object mysql_fetch_row mysql_field_flags mysql_field_len mysql_field_name mysql_field_seek mysql_field_table mysql_field_type mysql_free_result mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql_insert_id mysql_list_dbs mysql_list_fields mysql_list_processes mysql_list_tables mysql_num_fields mysql_num_rows mysql_pconnect mysql_ping mysql_query mysql_real_escape_string mysql_result mysql_select_db mysql_stat mysql_tablename mysql_thread_id mysql_unbuffered_query

Related stories

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...