Press "Enter" to skip to content

Tag: mysql

cPanel: Unable to upgrade from MySQL to MariaDB

Due to changes in the way MariaDB has setup their Centos yum repositories, cPanel (at the time of writing) is unable to access the necessary files to upgrade people from MySQL to MariaDB (as it needs to do it in stages and MariaDB 10.0 is no longer available).

Whilst the cPanel knowledgebase article entitled “Can’t upgrade from MySQL 5.6 to MariaDB” and cPanel have acknowledged it as an internal bug with the reference CPANEL-40434, they say there is “no workaround at this time”. This is incorrect!

As I posted on their forums in the “One of the configured repositories failed (MariaDB106)” thread (unfortunately my post – 14 hours on – is still pending moderation), there is a reasonably quick fix server administrators can do. Here’s the full text of the post “just in case”:

Since I’ve hit this problem on a new server migrating from MySQL to MariaDB (and my much earlier post about how to fix the general issue seems to have just expired rather than be approved), here’s what I did to fix it.

Platform: Centos v7.9 on x64 – migrating from MySQL 5.7 to MariaDB 10.6

If you do not have /etc/yum.repos.d/MariaDB102.repo , start an upgrade to MariaDB and let it die.

1. Copy /etc/yum.repos.d/MariaDB102.repo to /etc/yum.repos.d/MariaDB102-patch.repo
2. Modify /etc/yum.repos.d/MariaDB102-patch.repo to change the baseurl to https://archive.mariadb.org/mariadb-10.2/yum/centos7-amd64
3. Copy that file now as /etc/yum.repos.d/MariaDB103-patch.repo
4. Modify MariaDB103-patch.repo so “102” is changed to “103” throughout and the base URL has 10.3
5. Repeat steps 3 and 4 to go from “103/10.3” to “104/10.4” etc all the way up to 106/10.6
6. Do yum clean all;yum makecache
7. Go to the Database upgrade page (select “Ignore current upgrade” if necessary)
8. And upgrade!

Bit long winded and fiddly, but it worked for me(tm)

ClickCartPro: Extracting Sales Figures

If you want to get an idea of the stock you’ve sold using the ClickCartPro UK e-commerce software, then you may find the following SQL query useful. Run in phpMySQL to be able to export the data into a spreadsheet.

SELECT SUM(itemquan) as itemssold, count(*) AS timesordered, itemname, itemnum, itemopts, SUM(itemquan)/COUNT(*) AS average FROM `gbu0_orderitems` WHERE FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31’ GROUP BY itemnum,itemopts ORDER BY itemssold DESC

What does this mean?
Well, “SUM(itemquan) AS itemssold” grabs the number of items sold, “count(*) AS timesordered” grabs the number of times that item has actually been ordered (as an order could be for 2 or more items), “itemname, itemnum, itemopts” grabs the items name, item number and the options ordered (handy for sizes), “SUM(itemquan)/COUNT(*) AS average” works out the average number of items per order, “FROM `gbu0_orderitems`” says to look at the order table (ok, I’m not distinguishing between cancelled, pending and completed orders at the moment), “FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31′” says to only include orders placed between the 1st of January 2007 and the 31st of December 2008 and “GROUP BY itemnum,itemopts ORDER BY itemssold DESC” means group the items for the counts by the item number and options and then order everything by the number of times sold in decending order.