-   Linux - Newbie (
-   -   reset mysql password (

byran cheung 04-11-2014 04:41 AM

reset mysql password
I have a server ( live ) which have mysql database , I forget mysql root password , could advise if it is possible to copy the db to other server ( testing ) and then set root password ? as I would not to change live server mysql root password.


TenTenths 04-11-2014 04:50 AM

You can copy the physical files but you will have to stop your live MySQL instance during the copy process.

Then you can experiment with the recommended root reset procedure on your copy.

DinoFly 04-11-2014 04:55 AM

First stop your mysql server, than start it with option --skip-grant-tables


#mysqld_safe --skip-grant-tables
than login with user root:


#mysql --user=root mysql
and update the grant tables on mysql with your new password:


update user set Password=PASSWORD('new-password') where user='root';
flush privileges;

than just restart mysql server and you are good to go.

Here is an howto that describes the whole proces:

byran cheung 04-11-2014 05:36 AM

One more question , if I have 3 mysql databases in a server , could it set to individual password for each mysql db ? thanks

TenTenths 04-11-2014 05:40 AM

You can create as many users as you wish within MySQL.

Each user can have their own password and can have their own permissions on different databases.

I have a server that has 18 different databases for different websites, each of those websites has their own username/password/permissions. One of those websites has three databases and the user has permissions on all three of them. I also have other usernames with different permissions for replication and for backup.

If your next question is "how do I do this" then start another thread rather than having two different questions in the same thread.

All times are GMT -5. The time now is 09:13 PM.