How to update customer password in Magento 2 database?

UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('SaltPASSWORD', 256), ':SALT:1')
WHERE `entity_id` = 7615;

Please note that if SPJ9WIp7 is the salt and User’s password is 7qLzX33ETxYE, the following will be your query:

UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('SPJ9WIp77qLzX33ETxYE', 256), ':SPJ9WIp7:1')
WHERE `entity_id` = 7615;

7615 is the customer id

How to export multiple selected tables in PMA phpmyadmin (but not all tables)

Click on export, and choose “custom” export method.

Lets say you want to export first 20 tables only.

Open chrome or browser console [ctrl+shift+j], enter the following:


For next 20, use 20,50 as arguments in slice function used above.

Where are customizer settings stored in db for wordpress theme?

How to clone customizer settings in child theme from parent theme?

The customizer data is stored in table wp_options under option_name theme_mods_THEME-NAME

you can view all such settings via the following query:

SELECT * FROM `wp_options` WHERE `option_name` LIKE "theme_mods_%"

In some cases, you just want to use parent theme’s settings in newly added child theme. If that is your case too, use the following queries to utilize and close those settings for your child theme also.

update `wp_options` set `option_name`="theme_mods_YOURCHILDTHEME_backup" where `option_name`="theme_mods_YOURCHILDTHEME";
insert into `wp_options` (`option_name`,`option_value`,`autoload`) select "theme_mods_YOURCHILDTHEME",`option_value`,"yes" from `wp_options` where `option_name`="theme_mods_PARENTTHEME";

The following one is a bit risky one. If you understand what is going on here, go ahead.

delete from `wp_options` where `option_name`="theme_mods_YOURCHILDTHEME";
insert into `wp_options` (`option_name`,`option_value`,`autoload`) select "theme_mods_YOURCHILDTHEME",`option_value`,"yes" from `wp_options` where `option_name`="theme_mods_PARENTTHEME";

Fixing broken “screen options” in wordpress site

SELECT * from wp_usermeta where `meta_key` like 'edit_%_per_page'

So probably you chose “Number of items per page” as 1000 or 200 and now the page doesnt load anymore because your database ran out of memory.

If that is the case, run the above query on phpmysql or any other way, edit the numbers and fixed!

How to solve MySQL server gone away error Maria Db update on cPanel and WHM?

This is related to new MariaDb upgrade from 10.1.41 to 10.1.42 and also for servers which were updated from 10.2.27 to 10.2.28

Go to solution ( Special Thanks to @Valetia )

You will see errors in following formats/messages:

  • No file or input found
  • MySQL Server has gone away
  • Connection to MySQL Server failed
  • sqlstate[hy000]: general error: 2013 lost connection to mysql server during query
  • General error: 2006 MySQL server has gone away
  • ERROR 2006 (HY000): MySQL server has gone away
  • ERROR 2013 (HY000): Lost connection to MySQL server during query

Log files (/var/lib/mysql/$hostname.err) will have or can have any of these errors:

  • assertion fail /home/buildbot/buildbot/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/mariadb-10.2.28/storage/innobase/dict/ line 1467
  • the resulting row size is greater than maximum allowed size (8126) for a record on index leaf page
  • stack_bottom = 0x0 thread_stack 0x49000 mysys/stacktrace.c:268(my_print_stacktrace)[0x5564e62807bb] sql/[0x5564e5d4b4f5]

Other Symptoms:

/etc/init.d/mysql start
Starting MySQL/etc/init.d/mysql: line 159: kill: (10704) – No such process


yum downgrade MariaDB-* -y
whmapi1 update_updateconf RPMUP=manual UPDATES=manual

(run as root #)

This will downgrade MariaDb installation to previous version
Line 2 will cancel automatic update on WHM/CPanel installations

If you are not using WHM, use line 1 only OR you can downgrade the repository individually too

yum downgrade MariaDB-server MariaDB-common MariaDB-shared MariaDB-client MariaDB-compat MariaDB-devel


How to change attribute dropdown type to multi-select in Magento 2?

Short Answer:

Not possible via Magento2 Admin Backend.


You need to update eav_attribute table and edit information about backend_source, frontend_input etc.

Simple query for that is:

UPDATE `eav_attribute` SET `backend_model`="Magento\\\Eav\\\Model\\\Entity\\\Attribute\\\Backend\\\ArrayBackend", `backend_type`="varchar", `frontend_input`="multiselect", `source_model`=NULL WHERE `attribute_id`=YOUR_ATTRIBUTE_ID_INTEGER LIMIT 1

Replace YOUR_ATTRIBUTE_ID_INTEGER with your attribute_id like 355


How to disable products in Magento2 which dont have any gallery image?

UPDATE `catalog_product_entity_int` SET `value`=2 where `entity_id` in (SELECT a.`entity_id` FROM `catalog_product_entity` AS a LEFT JOIN `catalog_product_entity_media_gallery_value` AS b ON a.entity_id = b.entity_id LEFT JOIN `catalog_product_entity_media_gallery` AS c ON b.value_id = c.value_id WHERE c.value IS NULL) and `attribute_id` = 96

It is SQL query


value=2 means disable and value=1 means enable

attribute_id=96 means “status” attribute


How to wipe all the tables and data in MySQL? Clean whole database

SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
  FROM information_schema.tables
  WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;

Will not work via phpmyadmin or any script. this has to be run in cmd/terminal

Quick Command




How to reverse the ids in a mysql table column without breaking primary key constraint?

Let me explain the problem scenario: Let us assume we have a table with 4 columns in it out of which 1 is PRIMARY column and rest 3 contain some data.

What we want to do is to reverse the primary key IDs for that data keeping the rest of data intact. It is like shifting the first row to end and moving last row to starting.

Initial Data

1jacobwhateverhow to reverse
3nathanwhosoeverisnathanids in mysql table column
4jagmohanidontknowjagmohanwithout breaking
8monicaiamsexyprimary key constraint
9batmanidontexistinrealworldi am batman

Data after update

9jacobwhatever how to reverse
8nathanwhosoeverisnathan ids in mysql table column
4jagmohanidontknowjagmohan without breaking
3monicaiamsexy primary key constraint
1batman idontexistinrealworld i am batman

Dude, you are just reversing the column, what is so tough in this?

So, this seems simple to reverse an array if isolated by key “id“. But you have to understand that this column is the primary key. So if you run a command to change id for “jacob” to “9“. It will give you error: “Duplicate entry for id 9

So here is my proposed solution, I start with pair of first and last row and then swap them. Then swap second and second last row. and So on…

If total rows are odd, we will be left with 1 row which does not need correction because it will already be the middle row.

If total rows are even, we would swap middle two rows too.

Here is my solution in PHP

$ai=12720; //can be any high int which does not exist in column `id` yet
$q="select id,email from table_name where `possible_group_id`=$possible_group_id order by id asc";
echo "start transaction;<br>";
foreach($row_collection as $k=>$v)
    if($k < floor($size/2)){
    echo 'UPDATE `table_name` SET `id`='.$ai.' WHERE `email`="'.$row_collection[$size-$k-1][1].'";<br>';
    echo 'UPDATE `table_name` SET `id`='.$v[2].' WHERE `email`="'.$v[1].'";<br>';
    echo 'UPDATE `table_name` SET `id`='.$row_collection[$k][0].' WHERE `email`="'.$row_collection[$size-$k-1][1].'";<br>';}
    else break;
echo "commit;<br>";

It would output this:

start transaction;
UPDATE `table_name` SET `id`=12720 WHERE `email`="idontexistinrealworld ";
UPDATE `table_name` SET `id`=9 WHERE `email`="whatever";
UPDATE `table_name` SET `id`=1 WHERE `email`="idontexistinrealworld ";
UPDATE `table_name` SET `id`=12720 WHERE `email`="iamsexy";
UPDATE `table_name` SET `id`=8 WHERE `email`="whosoeverisnathan";
UPDATE `table_name` SET `id`=3 WHERE `email`="iamsexy";