To give a user admin rights in MySql you can use the following snippet.
Sample mySql Query
GRANT ALL PRIVILEGES ON myDbName.* TO 'myUserName'@'%' WITH GRANT OPTION;
To give a user admin rights in MySql you can use the following snippet.
GRANT ALL PRIVILEGES ON myDbName.* TO 'myUserName'@'%' WITH GRANT OPTION;
To select top 10 reads per month in WordPress, you need to use the Plugin CountPerDay.
The following mysql snippet will do the rest.
SELECT COUNT(page), wp_posts.post_title, wp_posts.post_name from wp_cpd_counter join wp_posts ON wp_posts.id = wp_cpd_counter.page WHERE wp_posts.post_date between '2014-06-01' AND '2014-06-30' GROUP BY page ORDER BY 1 desc LIMIT 10
To rearrange columns in MySQL you can use the following snippet.
ALTER TABLE TABLENAME MODIFY COLUMN COLUMNNAME TYPE AFTER COLUMNNAME
To copy a table in MySQL you can use the following snippet.
CREATE TABLE NEWTABLE LIKE OLDTABLE; INSERT NEWTABLE SELECT * FROM OLDTABLE;
To select entries less than 24 hours old in MySQL you can use the following snippet.
SELECT * FROM TABLENAME WHERE COLUMNNAME >= DATE_SUB(Now(),INTERVAL 24 HOUR)
To select a random row in MySQL you can use the following query.
SELECT COLUMNNAME FROM TABLENAME ORDER BY RAND() LIMIT 1
To replace a string in MySQL you can use the following snippet.
UPDATE TABLENAME SET FIELDNAME = REPLACE(FIELDNAME, 'ReplaceThis', 'WithThat') WHERE FIELDNAME LIKE '%ReplaceThis%'
To get the size of all databases in mysql you can use the following query.
SELECT table_schema "DBName", sum( data_length + index_length ) / 1024 / 1024 "size in MB" FROM information_schema.TABLES GROUP BY table_schema ;