Tag Archives: mysql server

MySQL: Drop all tables from Database using Script / Linux

Hello, Few days back, I got a task to do, Task was Keep the database as it is, So that we do not have to add database users, privileges and everything again and again, Just Drop all the databases tables inside the database. If there are only few tables like 5 or 10 than it […]

Read More

Reset MySQL Root Password Easily

Sometimes a system administrator forgets the MySQL root password! It happens, but what to do when you’re unable to login to your MySQL server? It’s simple!

All it takes is 5 simple steps!

Step 1: Stop the MySQL Server

We do this with:
/etc/init.d/mysql stop or service mysql stop

Step 2: Start the MySQL Server

mysqld_safe –skip-grant-tables &

We do this so MySQL ignores the root password we do not have! If you do not launch this command, resetting the MySQL password will not work!

Step 3: Login to MySQL Server

mysql -u root

Everything should be fine if you get the MySQL prompt!

Step 4: Change the MySQL Password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

NEW-ROOT-PASSWORD is your new root password that you want!

Step 5: Restart MySQL Server

/etc/init.d/mysql stop
/etc/init.d/mysql start

Now, you should have your new MySQL root password! I recommend you write it down this time!