Month: July 2014

Setting Up A Linux, Nginx, MySQL & PHP (LEMP) Stack On Debian 7

This will be a tutorial for setting up your own LEMP stack on Debian 7 Wheezy. This might be also used for installing one on Ubuntu but is not guaranteed.

LEMP Stack?

LEMP is almost the same with a LAMP stack but the Web server part is replaced with Nginx. LEMP is an acronym for a software bundle of Linux, Nginx(for E), MySQL and PHP. Sometimes any of this softwares gets replaced like MySQL can sometimes be replaced with MariaDB and PHP either Perl or Python. Continue reading

Setting Up A Linux, Apache, MySQL & PHP (LAMP) Stack On Debian 7

This will be a tutorial for setting up your own LAMP stack on Debian 7 Wheezy but this might also work for Ubuntu but is not guaranted.

What Is LAMP?

LAMP is an acronym for a software bundle that is Linux, Apache, MySQL & PHP. There are already available installer for this software stack like XAMPP which can be easily installed but if you want to setup your own LAMP stack using Debian aptitude then please read on. Continue reading

MySQL Procedure To Upper Case Table Names

Ever had an experience where you needed to rename a handful of table name into upper case. Below is a procedure to rename all tables into upper case in the current MySQL database/schema.

DELIMITER $$
 
DROP PROCEDURE IF EXISTS `PROC_TABLE_NAME_TO_UPPER_CASE`$$
 
CREATE PROCEDURE `PROC_TABLE_NAME_TO_UPPER_CASE`()
BEGIN
 DECLARE tbname TEXT DEFAULT ;
 DECLARE no_res INT DEFAULT 0;
 DECLARE cur CURSOR FOR
 SELECT t.table_name
 FROM information_schema.tables t
 WHERE t.table_schema = DATABASE() AND t.table_type=BASE TABLE;
 DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_res = 1;
 
 OPEN cur;
 
 rnloop: LOOP
 FETCH cur INTO tbname;
 
 IF no_res = 1 THEN
 LEAVE rnloop;
 END IF;
 
 SET @s = CONCAT(RENAME TABLE `, tbname , ` TO ` , UPPER(tbname), ` );
 PREPARE stmt FROM @s;
 EXECUTE stmt;
 END LOOP;
 
 CLOSE cur;
 
END$$
 
DELIMITER ;

Just run the script and call it using

CALL PROC_TABLE_NAME_TO_UPPER_CASE();

then it will rename the tables. Be reminded though that you need to specify the database to be used before connecting to MySQL or by using the use command.

© 2024 James Baltar

Theme by Anders NorenUp ↑