Monday, October 25, 2010

MySQL - resetting root password


In order to reset your root password for mysql:


  1. Find mysqld_safe application (usually in /usr/bin/mysqld_safe)

  2. Stop currently running mysqld process:

    /etc/init.d/mysqld stop


  3. Start mysql in a safe mode with --skip-grant-tables option using previously found path of mysqld_safe. This gives full access for all users with no passwords:

    /usr/bin/mysqld_safe --skip-grant-tables &


  4. Enter mysql:

    mysql


  5. Type:
    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;

    Mind that UPDATE and FLUSH should be in different lines.

  6. Restart mysql with usual settings:

    /etc/init.d/mysqld restart



Friday, October 22, 2010

Mail from command line

To send an email from command line you can use "mail" command.
Example:
echo "Message body" | mail -s "Test_subject" example@exampledomain.com
Sends message "Message body" with a subjects "Test_subject" to example@exampledomain.com