If you have noticed there is an exclamatory sign (!) after the post title, let me tell you I have deliberately placed it to express my surprise on the whole thing which I’m going to share. I have been working with MySQL since early 2005, if I remember correctly it was version 4.1 which for the first time supported Sub Queries. I was a pure MySQL newbie back then and did not have any idea about how good or bad MySQL was. Honestly I switched from Microsoft Technologies to Open Source Technologies because my employer decided to switch to Open Source to avoid license costs, for obvious reasons I was skeptical about Free and Open Source MySQL and though very highly of MSSQL & MMC Console Microsoft offered! Since then till I faced the MySQL ORDER BY issue in Cloud I have used MySQL ORDER BY to solve all kinds of ranking problems, though I always knew MySQL sorting algorithm is not a great one, inside it uses qsort (quicksort) algorithm but if use the ORDER BY on a indexed field / key then it won’t cause much of an optimization issue. [Read more…]
A Few Useful MySQL Commands / Queries for Amateur DBAs – Part 1
I consider myself an amateur DBA because I’m not a professional MySQL DBA but at times I have to work with some MySQL Commands / Queries which are piece of cake for professional DBAs but require me to Google every time I need to use them. Currently some of them are lying in my GMail’s draft and some are lying in a Google Drive Doc and for the rest of them I still need to Google!! One Monday morning decided to create a ready reference out of those Commands / Queries and publish under my Blog for all future requirements and for other amateur MySQL DBAs out there in the World Wide Web!
1. Login to MySQL Command Prompt as root user
#mysql -uroot -p (this will require you to enter password after you press the return key)
OR
#mysql -uroot -prootpwd (here “rootpwd” is the password for root user)
Using the full MySQL Server path: /usr/local/mysql/bin/mysql -uroot -p OR /usr/local/mysql/bin/mysql -uroot -prootpwd
How to rename a stored procedure in MySQL?
If you have a situation in hand where you need to rename a STORED PROCEDURE in MySQL and not DROP it then there are 2 ways I could figure out to tackle it. Before I start describing the methods I would like to state why I needed to rename a STORED PROCEDURE in MySQL?
I always have a STORED PROCEDURE named as “x” in all my projects databases where I write temporary code to tackle a particular problem and when the experiment is successful I create a new STORED PROCEDURE and copy & paste code from “x” PROCEDURE. I was following this process for quite some time happily, but then came a situation where it looked time consuming and I needed a faster method!
I found Method 1 by Google-ing and Method 2 was my sudden discovery!
Method 1: Rename a STORED PROCEDURE
SET name = ‘<new_proc_name>’,
specific_name = ‘<new_proc_name>’
WHERE db = ‘<database>’ AND
name = ‘<old_proc_name>’;
So if I want to rename my “x” PROCEDURE to “new_x” the statement would look like the following:
UPDATE `mysql`.`proc`
SET name = ‘new_x’,
specific_name = ‘new_x’
WHERE db = ‘db_mydb’ AND
name = ‘x’;
Please Also note: If you have granted privileges to users for this procedure you will need to update the procedure name in procs_priv as well.
UPDATE `mysql`.`procs_priv`
SET Routine_name = ‘<new_proc_name>’
WHERE Db = ‘<database>’ AND
Routine_name = ‘<old_proc_name>’;
FLUSH PRIVILEGES;
You can execute the above queries from MySQL GUI Tool like MySQL Query Browser or MySQL Command Prompt.
Method 2: Rename a STORED PROCEDURE with a backup
This method is my sudden discovery and I figured it before I found Method 1 by Google-ing and I execute it in MySQL Query Browsers (needless to say it is still my favorite tool to operate MySQL!)
– Select the PROCEDURE “x” and press F2 or right click and select “Edit Procedure”
– PROCEDURE opens in the Query Browser Editor
– Modify DROP PROCEDURE IF EXISTS `db_mydbs`.`x` to DROP PROCEDURE IF EXISTS `db_mydbs`.`new_x`
– Modify CREATE PROCEDURE `db_mydb`.`x` () to CREATE PROCEDURE `db_mydb`.`new_x` ()
– Click to Continue button
The above steps create a new PROCEDURE named “new_x” and also keeps the PROCEDURE named “x” intact.
I generally use Method 2 because it lets me keep my handy “x” PROCEDURE intact and create another PROCEDURE with the same code in a mouse click. Method 2 may not sound very scientific or authentic but since MySQL respond to it quite nicely I guess it is not as bad :).
© Kamalika Guha Roy
How To Deploy Ruby on Rails in Godaddy?
- Login to Godaddy Control Panel
- Click on My Account
- Click on Hosting
- This page will display active domains that are hosted within that Godaddy hosting space
- Click on Manage (on whichever domain you want to deploy Ruby on Rails application/project)
- In the hosting manager click on CGI-Admin under Content section
- Login to CGI-Admin using your hosting account user name and password
- From Ruby tab create your Ruby/Ruby on Rails application directory
- Above step will create a folder under hosting space and one .htaccess file under that folder
- Edit .htaccess file and change the file from despatch.cgi to despatch.fcgi
- Open a FTP client
- Download their demo application
- Create our controller, model, view in that demo application using ruby script generator
- Check it locally
- Upload the whole application (along with the rails distribution in the vendor folder) to the folder that created from CGI-Admin
- From browser the path will be http://www.mysite.com/<myapplication-folder>/public/<controller>/<action>
Creating Backup Schedule in RHEL 5
Creating Backup Schedule in RHEL 5:
- Open Putty
- Login to the server (entering server IP)
- Login to server using user name and password from the Putty SSH Console
- To create a CRON schedule type:crontab –e <enter>
- VI text editor will open as a blank file for the “crontab entries” to be entered; each line represents a separate crontab entry (hereafter referred to as “CRON JOBS”).
- Each CRON JOB has at least 6 sections. Each section is delimited by a single blank space, but the final section may have spaces within it. No spaces are allowed within Sections 1-5, blank spaces are allowed only between those sections. Sections 1-5 are to indicate when and how often you want the task (the sixth position) to be executed and it uses the system time for execution.
- Here is how positions 1-5 are laid out:
1 Minute 0-59
2 Hour 0-23 (0 = midnight)
3 Day 1-31
4 Month 1-12
5 Weekday 0-6 (0 = Sunday)
An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used.
- Backup script within the crontab entry is
* 14 * * 5 root tar czpvf /home/user/backup-$(date +%Y-%m-%d).tar.gz /opt/lampp
- The CRON is set to 1400 hour (2:00 p.m.) 5th day of week (Friday)
- The command that will execute is
tar czpvf /home/user/backup-$(date +%Y-%m-%d).tar.gz /opt/lamppThis above command will tar the entire content of the directory /opt/lampp and put the tar file into /home/user/
The name of the tar file will be backup-$(date +%Y-%m-%d).tar.gz (backup-YYYY-MM-DD.tar.gz)
- « Previous Page
- 1
- …
- 3
- 4
- 5
- 6
- 7
- Next Page »