How do I create a new user and password in wordpress using phpmyadmin and the site's mysql database dump?

Hi all,

A friend of mine has just passed a couple of sites he hosted on a shared server.
He had a spat with the owner who is also a programmer and this resulted in them falling out.
It so happens that he managed to recover all his site's wordpress files from the ftp and also the
database mysql file from the phpmyadmin interface. Sadly the sites have now been cancelled from the original server.
I have copied the files to my server, uploaded the db to a new one on my phpmyadmin.
However since the site was maintained and updated by this third party, after their fight
he never gave my friend his admin login and password.

Is there a way by using let's say phpmyadmin or even the linux ssh console of the server
(I have a private VPS and I can access the server using putty) to create a new user in the wordpress database
and assign a new password to him, so that I might login to the website and make the needed updates?

thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
Look in the wp_users table using PhpMyAdmin. There, you can get the admin's user name and email address. Attempt to log in to the Wordpress site, type in the admin's user name and click "Lost your password?" A reset link will be sent the the email address. If necessary, you can change the email address to one you have access to before you begin.
Jason C. LevineNo oneCommented:
Exactly.  Just change the email address of the first user in the wp-users table (typically the admin user) to something you control and do a normal password reset from there.  

There's other ways to do it, though.  Here's a fun one:

function add_admin_acct(){
	$login = 'myacct1';
	$passw = 'mypass1';
	$email = '';

	if ( !username_exists( $login )  && !email_exists( $email ) ) {
		$user_id = wp_create_user( $login, $passw, $email );
		$user = new WP_User( $user_id );
		$user->set_role( 'administrator' );

Open in new window


Nice, huh?  A little code injection and you're an admin.
badwolfffAuthor Commented:

there is something wrong with both your approaches in that these sites have an smtp issue too.
They were on another server before and the smtp configuration there was related to an email address which expired with the old domain. So when I try to send myself and email I get nothing.

Does anyone know a method that might allow me to use the linux SSH console (putty) to create a new user or find an existing user's name and change his password, using the mysql server prompt?

thanks in advance
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tom BeckCommented:
Can't speak to the SSH console method.

Do you have access to another working installation of Wordpress and PhpMyAdmin? Create a new user name and password there. Go to PhpMyAdmin and copy the hash value of the password. Open the broken WP installation in PhpMyAdmin and paste the password hash into the entry for the admin account.

I don't recall ever entering specific smtp configuration into any WP installation unless I was using an email enhancer plugin. My understanding is that WP just opens an smtp connection on the host server without asking questions. Obviously you cannot relay through the old server now that you're on a different server but why would WP be attempting to do that? Is there an email plugin installed? Disable it and see if you get an email.

Another possible option is to open the functions.php file for the theme and write a function to over ride the smtp configuration as described here.
Jason C. LevineNo oneCommented:
there is something wrong with both your approaches in that these sites have an smtp issue too.

Technically, there's nothing wrong with OUR approaches.  The mail issue is just a separate thing :)

So when I try to send myself and email I get nothing.

I would think your easiest course of action is to disable the SMTP stuff if it really is an SMTP issue but other things may be at work here. Some ISPs do not allow mail() to send messages unless the sending address matches the site domain (kind of a redneck open relay protection) and your server may have other issues with deliverability of messages.  In any event, I would add an SMTP plugin and also sign up for a free Mandrill account and use that server to send all WordPress email.  It should bypass the issues you are currently describing.

an existing user's name and change his password, using the mysql server prompt?

Not sure this would work because WordPress runs the passwords through a hashing function and stores that.  It's trivial to change the password in the database but without the hash, you still couldn't login.

My understanding is that WP just opens an smtp connection on the host server without asking questions.

Sort of.  In its default state, WordPress just opens up a mail() instance and pumps mail out that way.  You can force it to use an SMTP connection instead, which I strongly recommend people do.
badwolfffAuthor Commented:
ok boys thanks for the input
when I get to office tomorrow I will try the lot :)
when I said there is something wrong, I did not mean to offend, as what I was intending to say was
that for some reason these approaches are not producing the result for me :)
thanks for the answers
Jason C. LevineNo oneCommented:
I did not mean to offend

You didn't, hence the emoticon. I did want to make it clear that the solutions are technically valid so a future user can try it and the email thing is a a different, albeit severe, issue.
Sam CohenConsultant to Digital/DeveloperCommented:
This is how you would do it in phpmyadmin:

Edit the wp_users table. Find any username. Change it's current password hash (example: $3tyh~24eXrt...........) to:


then click the Save button (or Go button).

Then login into Wordpress and and use "admin", as the password. Once logged in simply change the password to whatever you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.