MySQL string replace

khaled —  March 9, 2012 — 1 Comment

One of the MySQL functions that is extremely useful is the MySQL REPLACE() function. The REPLACE syntax looks as follows:

REPLACE(str,from_str,to_str)

For example, if for some reason you need to update the links in your body fields and replace all your current links URL with new links URL you can use the following query:
update my_table set body=replace(body,’http://www.example1.com’,’http://www.example2.com’);

 

1. Install Apache 2.4 from source:

1.1 Prerequisites:

For installing Apache2.4 on Debian you need APR library. You can install this using the following command:

apt-get install libaprutil1 libaprutil1-dev

1.2  Download Apache2.4:

Download the latest version from here: http://httpd.apache.org/download.cgi#apache24
Go to /usr/src directory and download the latest version.

cd /usr/src
wget http://lnx.apollo-hw.ro/apache//httpd/httpd-2.4.1.tar.gz

1.3. Extract and Install Apache2.4:

Continue Reading…

Sometimes, while trying to run a query that contains large data size in MySQL, you will receive the following error: “Got packet bigger than ‘max_allowed_packet’ bytes”. This error is very common when dumping, restoring or inserting content that contains blob or large strings of data.

In order to resolve this error, all you need to do is to locate the used my.cnf and increase the max_allowed_packet variable. It is generally recommended to set it to 32M.

On Debian distributions, the cnf file is generally located at /etc/mysql/my.cnf.

Percona Server is based on MySQL 5.5.19, Percona Server 5.5.19-24.0 is now the current stable release in the 5.5 series.

All of Percona ‘s software is open-source and free.

Whats new:

  • Variable innodb_flush_neighbor_pages can be now set to a new value cont. The previously-available option values 0 and 1 now have more descriptive names none and area. The value of none disables the neighbor page flush and area matches the default InnoDB behavior: any dirty pages in the vicinity of the page selected for flushing may be flushed too. The new option value cont improves the neighbor flushing by considering only contiguous blocks of neighbor pages, thus performing the flush by sequential instead of random I/O. (Yasufumi Kinoshita, Laurynas Biveinis)
  • Improvements to the XtraDB’s sync flush algorithm. If the XtraDB checkpoint age grows dangerously close to its limit and XtraDB is forced to perform a sync flush, these changes should slightly improve the user query performance instead of completely blocking them. (Yasufumi Kinoshita, Laurynas Biveinis)

You can download Percona Server from here or from  Percona Software Repositories

Percona is glad to announce the release of Percona Server 5.1.60-13.1 on December 16, 2011 (Downloads are available from Percona Server 5.1.60-13.1 downloads and from the Percona Software Repositories).

Based on MySQL 5.1.60, including all the bug fixes in it, Percona Server 5.1.60-13.1 is now the current stable release in the 5.1 series. All of Percona ‘s software is open-source and free, all the details of the release can be found in the 5.1.60-13.1 milestone at Launchpad.

Bug Fixes

  • SHOW SLAVE STATUS could give incorrect output with master-master replication and using SET user variables. This could only occur with a sever having both master-master replication and --log-slave-updates enabled. This is also filed in MySQL bug tracker, but not fixed in upstream MySQL at the time of this Percona Server release. Bug Fixed: #860910 (Alexey Kopytov)
  • MyISAM repair-by-sort buffer cannot be more than 4GB even on 64bit architectures. With this bug fix, both the server option --myisam-sort-buffer-size and the |myisamchk| --sort-buffer-size can be set to values over 4GB on 64bit systems. For users with large MyISAM tables, this could be a great improvement in |myisamchk|, CREATE INDEX and ALTER TABLE performance. Bug Fixed: #878404 (Alexey Kopytov)
  • The atomic operations used in Response Time Distribution on 32bit systems could (in theory) be optimized incorrectly by the compiler. This has not been observed in the wild and may only be an issue with future compilers. With this bug fixed, we have corrected the inline assembly to always produce correct compiled code even if future compilers implement new optimizations. Bug Fixed:#878022 (Laurynas Biveinis)
  • GCC 4.6 has expanded diagnostics and compiler warnings. We have audited and fixed these warnings for Percona Server 5.1, finding that the warnings were benign. Bug Fixed #878164(Laurynas Biveinis)
Page 3 of 512345