Browsing all articles tagged with password

How To Reset MySQL Password

If you are like me who tend to forget passwords almost every time, then this tip might help you reset your MySQL password just in case.

To begin, you must have access to the server, one that can stop and start the MySQL process, such as a root account. Sudo account can also be used, just as long that the user can control the MySQL service.

Begin the process by stopping the MySQL process. This can be done by executing /etc/init.d/mysqld stop command, but this can vary depending on how you setup your server. Also, be careful of users who might be using the MySQL service as stopping the service might disrupt their work.

Once the MySQL process is killed, execute the following command:

mysqld-safe --skip-grant-tables

This will run the MySQL process so you need to open another terminal to be able to reset the password. On the new terminal, you will now be able to login to MySQL to reset the password.

On the shell prompt of the new terminal, open the MySQL console:


mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD(‘YOUR_NEW_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;
mysql> exit

This will change the password for the user ‘root’. Kill the MySQL process running in the first terminal, either by killing the PID or executing CTRL+C. Then start the process again, this time with the proper procedure:

/etc/init.d/mysqld start

Try logging in to the MySQL console using the new password:

mysql –uroot -p

You should now be able to use the new password for your MySQL.


Tip: Add User and Generate Password Script

Hey guys!

Finally, I found time to update this lovely blog of mine. And luckily, I have one super cool simple script to share. This script will help a lot of system administrators in adding user accounts, very useful if you have about a hundred servers to login to and execute useradd and passwd again and again. This is a bash script, so no need to install packages and easy to understand.

Here goes the code.


for USER in $(cat /tmp/users.txt) do
$(useradd $USER)
###Remove the space between 8 and )
PASSWORD=$(openssl rand -base64 8 )
###passwd [double dash] stdin
echo $PASSWORD | $(passwd –stdin $USER)
echo “$USER $PASSWORD” | mail -s “Your Account Info” $
sleep 3

Here is a quick summary of the code per line:

for USER in $(cat /tmp/users.txt) do
This line begins the for loop and /tmp/users.txt should be a text file containing the list of usernames to be added one username per line. The value of $USER

$(useradd $USER)
This line will begin by executing the command useradd. If the script fails at this point because the username already exists, it will proceed with changing the password of the username.

###Remove the space between 8 and )
###passwd [double dash] stdin
PASSWORD=$(openssl rand -base64 8 )
echo $PASSWORD | $(passwd --stdin $USER)

This line generates an 8-byte random password using openssl and pipes it to command passwd using –stdin option so the generated password can be passed.

echo "$USER $PASSWORD" | mail -s "Your Account Info" $
This line sends an email to the user containing the username and password, assuming that the email address is the same as the username.

This script can be further enhanced (imagination is limitless!) and feel free to share your script here.


Secure Files with Your IronKey

Working as a system administrator requires a lot of memory power with all the servers that I am managing at work. Not to say the huge amount of passwords that go with it. And I must admit that my memory is not to be trusted (hey, even Einstein once suggested not to trust your memory!) with these credentials that if compromised or forgotten, will mean death to my career.

Anyway, my boss from our California office gave me a little piece of technology that I carry around with me and though I have read it a few times before, I never got the chance to own one. I am talking about the IronKey, a military-grade secure flash drive that is designed to protect the stored files.

This drive claims to be the most secure drive in the world. It’s design lies in its hardware-based AES encryption that resists any attempt to bypass the password, and provides a tight security for the drive. It also protects your encrypted data from brute-force attacks by initiating a self-destruct process if the password is typed in incorrectly after the tenth try. Any attempts also to tamper the casing will trigger the drive to self-destruct the data, making sure that no one will get the data even if physically tampered.

The bundled software also provides the security needed to access the files by asking for a password to unlock the USB drive. Locked drive means no read-write access whatsoever. Secure backup is also provided so encrypted backups of the contents can be created without compromising the data.

All in all, IronKey is perfect for confidential files and should be the standard of all USB flash drives.


Tip: Testing Your PHP/MySQL Connection

How to test if PHP connects to MySQL database?

There are numerous times when I have to setup Apache and PHP on a freshly installed Linux server. Considering that not only that Apache service should work, I also have to make sure that PHP and MySQL are working properly together.

Forgetful that I am, I always tend to forget what components should I have to make PHP and MySQL talk to each other. You need something like a ‘special glue’ to connect the two together and I will discuss here how to make PHP and MySQL work together for both RPM and source installation.
read more


Linux Tip: Reset Root Password

How to reset root password?

If you are as forgetful as I am, you have probably forgotten what password you have set for root user. Today, I am going to teach you a little tip on how to reset the root password.
read more

Powered by 1and1.comDomain Registrations starting at $9.98* Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Recent Comments

Site Stats