Archive for the ‘MySQL’ Category
MySQL functions to count occurences of specified char or string
Let’s say our column in named ‘col’ and table is named ‘t2′.
Count occurrences of specified character within a string
SELECT
LENGTH(
REPLACE(col, ‘.’, ‘@@’)
) -
LENGTH(
col
)
FROM t2
Will count number of occurrences of character ‘.’ in column ‘col’
Count occurrences of specified substring within a string
SELECT
ROUND((
LENGTH(
REPLACE(col, ‘ab’, REPEAT(‘ab’, 2))
) -
LENGTH(
col
)
) / 2)
FROM t2
Will count number of occurrences of substring ‘ab’ in [...]
MySQL error: MySQL server has gone away
Recently I tried to import a huge database and I got an error saying:
[code]ERROR 2006 (HY000) at line 216: MySQL server has gone away[/code]
Solving this error is quick and easy and all you have to do is edit my.ini file from you MySQL installation directory.
URL related simple MySQL functions
Below you can find simple MySQL code snippets to extract various information from URLs stored in a database table.
How to dump MySQL database and split into 10 MB files on the fly
Recently I had to dump a database that was too big to dump with with phpMyAdmin and I couldn’t just use mysqldump tool from command line because there was a 10 MB file size limit on the server.
How to reset admin password in Magento, Wordpress, Joomla…?
Getting admin password is a complicated task, because different websites use different hashing algorithms.
So- here’s a nice application which does the trick- it allows you to generate new admin password for websites powered by: Mantis, Joomla, Wordpress, Mambo, vBulletin, Typo3, phpBB, Drupal, Prestashop or Magento.
What SQL queries PHP scripts execute (without looking in the code)?
Sometimes I need to check what SQL queries is PHP script executing, but when code is quite complex (or encoded with Zend Guard or IonCube) it is extremely hard or even impossible to get this information from php files.
So- here’s a nice solution for this problem. It will log all the SQL queries send to the MySQL server in a MySQL table.
How to move Magento shop to another host?
To successfully move a Magento store to another host (including localhost) you can just follow the steps above.