This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
switch($_SERVER['SERVER_NAME']) | |
{ | |
case 'localhost': | |
case 'LAN.IP.ADD.RESS': | |
$database_hostname = 'DATABASE_HOSTNAME'; | |
$database_username = 'DATABASE_USERNAME'; | |
$database_password = 'DATABASE_PASSWORD'; | |
$database_name = 'DATABASE_NAME'; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://stackoverflow.com/questions/10628640/get-full-mysql-query-string-on-insert-or-update | |
-- SELECT info FROM INFORMATION_SCHEMA.PROCESSLIST WHERE id=CONNECTION_ID(); | |
USE test; | |
CREATE TABLE test_entry (id INTEGER(10) NOT NULL DEFAULT 0); | |
CREATE TABLE `log_queries` ( | |
`query_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Query ID', | |
`query_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Query ran on time', | |
`query_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Query made on table', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://mysqlhints.blogspot.ae/2011/01/how-to-log-user-connections-in-mysql.html | |
-- http://stackoverflow.com/questions/2627058/get-current-session-process-id-from-inside-a-mysql-query | |
-- http://www.xaprb.com/blog/2006/07/23/how-to-track-what-owns-a-mysql-connection/ | |
-- http://www.softtreetech.com/idbaudit.htm | |
DROP TABLE IF EXISTS mysql.audit_connections; | |
CREATE TABLE mysql.audit_connections ( | |
`audit_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Audit ID', | |
`connections_counter` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Total number of connections', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://forums.mysql.com/read.php?108,201578,201578 | |
SELECT | |
table_schema "Data Base Name", | |
SUM( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", | |
SUM( data_free )/ 1024 / 1024 "Free Space in MB" | |
FROM information_schema.TABLES | |
GROUP BY table_schema; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT("SHOW GRANTS FOR '", USER, "'@'", HOST, "';") FROM mysql.user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT(USER, '@', HOST) FROM mysql.db WHERE db='database_under_risk'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE PREFIX_DATABASE CHARACTER SET utf8 COLLATE utf8_general_ci; | |
GRANT ALL ON PREFIX_DATABASE.* TO 'PREFIX_USERNAME'@'%' IDENTIFIED BY 'RANDOM_PASSWORD'; | |
GRANT ALL ON PREFIX_DATABASE.* TO 'PREFIX_USERNAME'@'localhost' IDENTIFIED BY 'RANDOM_PASSWORD'; | |
-- mysql -hlocalhost -uPREFIX_USERNAME -pRANDOM_PASSWORD PREFIX_DATABASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE target.table; | |
CREATE TABLE target.table LIKE source.table; | |
INSERT INTO target.table SELECT * FROM source.table; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
/** | |
* Add a script element as a child of the body | |
*/ | |
function attachJS() | |
{ | |
var element = document.createElement("script"); | |
element.src = "js/attached.js" | |
document.body.appendChild(element); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm -rf `find . -type d -name .svn` |