Showing posts with label PhpMyadmin. Show all posts
Showing posts with label PhpMyadmin. Show all posts

Friday, October 11, 2024

Create an admin account in WordPress via MySQL

INSERT INTO `wp_users`(

    `user_login`,

    `user_pass`,

    `user_nicename`,

    `user_email`,

    `user_status`

)

VALUES(

    'admin999',

    MD5('password999'),

    'firstname lastname',

    'email@example.com',

    '0'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_capabilities',

'a:1:{s:13:"administrator";s:1:"1";}'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_user_level',

'10'

);

Wednesday, November 2, 2022

Find All Rows Containing Duplicates using SQL CMD

SELECT

    a.*

FROM

    users a

JOIN(

    SELECT

        username,

        email,

        COUNT(*)

    FROM

        users

    GROUP BY

        username,

        email

    HAVING

        COUNT(*) > 1

) b

ON

    a.username = b.username AND a.email = b.email

ORDER BY

    a.email

Tuesday, April 19, 2022

Decrease product price by 10% using SQL command in Woocommernce from Phpmyadmin

 Query-1:

UPDATE

   wp_wc_product_meta_lookup

SET

    min_price =(min_price - min_price * .13)

WHERE 1;

Query-2;

 UPDATE

   wp_wc_product_meta_lookup

SET

    max_price =(max_price - max_price * .13)

WHERE 1;

Friday, March 11, 2022

How to Delete All Products in WooCommerce using SQL Command?

  1. Log in to the phpMyAdmin portal
  2. Select the database that has all the products to be deleted. Make sure, that you backup your database before executing the SQL statement!
  3. Than select table {prefix}_posts and run the SQL statement as shown.


DELETE relations.*, taxes.*, terms.*

FROM metro4u_term_relationships AS relations

INNER JOIN metro4u_term_taxonomy AS taxes

ON relations.term_taxonomy_id=taxes.term_taxonomy_id

INNER JOIN metro4u_terms AS terms

ON taxes.term_id=terms.term_id

WHERE object_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));


DELETE FROM metro4u_postmeta WHERE post_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));

DELETE FROM metro4u_posts WHERE post_type IN ('product','product_variation');


Note: "metro4u" is a prefix. Set your Database Table prefix

How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...