Reset your MYSQL Password

Hi friends,

After long time, today i thought of use my MYSQL db, But the thing is i’ve forget my password 😦  Then i asked to my friend mani, “pls help me mani, i ve to reset my MYSQL password urgently. He gave the simple solution”. 🙂

Here the i’m posting the simple steps to reset the mysql root password.

Open your terminal and type the following commands.

First we’ve to stop the mysql service,

  $ sudo service mysqld stop
 $ sudo mysqld_safe --skip-grant-tables

( It runs the mysql in safe mode and the “skip-grant-tables ” skips the table which ‘ve the MYQSL  user passwords )

The above command ‘ll start mysql server, now open a another tab in ur terminal and type this command.

$  mysql --user=root mysql  ( It 'll login as root without password)

Now type the below query in myqsl prompt.

Note: change “new-password” to your new password.  🙂

> update user set Password=PASSWORD('new-password') WHERE User='root';

That’s all     ve fun 🙂

Interchange characters in Ruby string

Hi friends,

In ruby we can interchange characters in a string easily by using “.tr” methods this is a good useful method to perform some replace actions on strings.

Returns a copy of str with the characters in from_str replaced by the corresponding characters in to_str.

Here are few examples on this method:

This is the Example for Exchange the ‘aeiou’, ‘_
=> “Th_s _s th_ Ex_mpl_ f_r Exch_ng_ th_ str_ngs.
‘This is the Example for Exchange the strings.’.tr ‘a-k’, ‘*’
=> “T**s *s t** Ex*mpl* *or Ex***n** t** str*n*s.”

‘This is the Example for Exchange the strings.’.tr ‘a-z’, ‘s’
=> “Tsss ss sss Essssss sss Esssssss sss sssssss.”

‘This is the Example for Exchange the strings.’.tr ‘aeiou’, ‘5’
=> “Th5s 5s th5 Ex5mpl5 f5r Exch5ng5 th5 str5ngs.”