Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation of "replace" utility in mysql: what's the alternative?

Tags:

replace

mysql

I use the replace utility (mysql/5.7.21/bin/replace) in our scripts as it has pretty simple syntax and much easier to use in comparison to "sed". However, with a mysql version upgrade, I have started getting the following:

Warning: replace is deprecated and will be removed in a future version.

Noticed that the utility is planned to be removed with MySQL 8.0.

Reference: https://dev.mysql.com/doc/refman/5.7/en/replace-utility.html

Do we know about any similar alternative that MySQL is going to introduce?

like image 923
Arnab Avatar asked Oct 15 '25 06:10

Arnab


1 Answers

Answer by Bill Karwin is incorrect.

The replace utility shipped with various MySQL distributions and the one from replace.richardlloyd.org.uk are completely different programs, with different syntax and by different authors.

Replace utility as shipped by MySQL

  • Example use to illustrate syntax: replace foo bar -- file.txt. Multiple replacements can be specified by putting them before -- delimiter, e.g.: replace foo bar lorem ipsum -- file.txt.
  • Authored by someone named Monty and copyrighted by Oracle Corporation
  • Case sensitive always
  • I rewrote in plain C (without MySQL headers) and made available at https://github.com/dvershinin/replace

Replace utility by Richard K. Lloyd

  • Uses entirely different syntax. To specify multiple replacement pairs, -a switch can be used, e.g. replace foo bar -a lorem ipsum file.txt. Multiple -a switches can be used.
  • Authored by Richard K. Lloyd
  • Case insensitive by default. Case sensitive search can be enabled with -e switch.
  • Is packaged as binary for CentOS / RHEL and can be deemed an alternative to users of replace utility shipped for MySQL:

As put here, both programs have been packaged for CentOS / RHEL, e.g:

yum install https://extras.getpagespeed.com/release-latest.rpm

Then, for Richard K. Lloyd's replace:

yum install replace2 

Or, for the Oracle's replace (its syntax rather):

yum install replace 
like image 131
Danila Vershinin Avatar answered Oct 16 '25 21:10

Danila Vershinin