Você já esqueceu a chave de casa e se sentiu preso do lado de fora? Ficar sem acesso ao seu site WordPress pode ser muito parecido com isso. É muito frustrante, especialmente se os hackers excluíram sua conta de administrador. Mas não se preocupe, você pode voltar a entrar.
Pense em seu site como uma casa com uma porta secreta nos fundos. Essa porta dos fundos é o banco de dados do seu site, que geralmente é acessado por meio do código MySQL. Isso pode parecer complicado, mas é como um conjunto de instruções que você pode usar para fazer alterações em seu site nos bastidores.
Neste artigo, vamos ensiná-lo a usar o MySQL para criar uma nova conta de administrador para o seu site, assim como fazer uma nova chave para a sua casa. Dessa forma, você pode bloquear os hackers e retomar o controle.
Por que adicionar um usuário administrador ao banco de dados do WordPress via MySQL?
Certa vez, tivemos um problema em que o site de um usuário foi invadido e sua conta de administrador foi excluída do banco de dados. Isso o impediu de acessar o site do WordPress.
Conseguimos ajudá-los a obter acesso ao site criando um novo usuário administrador diretamente no site do WordPress. Fizemos isso usando o phpMyAdmin, uma ferramenta baseada na Web que permite gerenciar bancos de dados MySQL usando o navegador da Web.
Se você se encontrar bloqueado fora da área de administração do WordPress devido a hackers ou simplesmente porque esqueceu a senha, poderá fazer o mesmo.
No entanto, você deve sempre fazer um backup do seu banco de dados antes de realizar qualquer edição do MySQL. Depois, quando puder fazer login novamente em seu site, talvez seja necessário seguir nosso guia para iniciantes para corrigir seu site WordPress invadido.
Dito isso, vamos dar uma olhada em como adicionar um usuário administrador ao banco de dados do WordPress via MySQL.
Como adicionar um usuário administrador ao banco de dados do WordPress com o phpMyAdmin
O phpMyAdmin vem pré-instalado na maioria das principais empresas de hospedagem WordPress. Você pode encontrá-lo na seção Databases (Bancos de dados) do painel cPanel da sua conta de hospedagem.
Aqui está uma captura de tela do painel de controle da Bluehost:
Clicar no ícone abrirá a interface do phpMyAdmin. Você precisa selecionar o banco de dados do WordPress na coluna da esquerda.
Depois disso, o phpMyAdmin exibirá todas as tabelas em seu banco de dados do WordPress. Você fará alterações nas tabelas wp_users
e wp_usermeta
.
Adição de um usuário à tabela wp_users
Primeiro, você precisa localizar a tabela wp_users
e clicar nela. Isso mostrará os usuários atualmente listados na tabela.
Observe na captura de tela abaixo que há dois IDs de usuário na tabela do nosso site de demonstração, 1 e 2. Quando criamos um novo usuário para o nosso site de demonstração, esse ID precisa ser exclusivo, portanto, digitaremos o número 3.
Você precisa clicar na guia “Insert” (Inserir) na parte superior da tela para poder inserir as informações de um novo usuário administrador.
Adicione as seguintes informações aos campos do formulário Inserir:
ID
: escolha um número exclusivo (em nosso exemplo, usaremos 3)user_login
: o nome de usuário que será usado ao fazer loginuser_pass
: adicione uma senha e certifique-se de selecionar MD5 no menu de funções (veja a captura de tela abaixo)user_nicename
: o nome completo ou o apelido do usuáriouser_email
: o endereço de e-mail do usuáriouser_url
: o endereço do seu siteuser_registered
: selecione a data e a hora em que o usuário foi registrado usando o calendáriouser_activation_key
: deixar em brancouser_status
: defina esse valor como 0display_name
: o nome completo ou o nome de exibição do usuário
Quando terminar, certifique-se de clicar no botão “Go” (Ir) para armazenar o novo usuário.
Adição de um usuário à tabela wp_usermeta
Agora, você precisa localizar a tabela wp_usermeta
e clicar nela. Depois disso, você deve clicar na guia “Insert” (Inserir), como fez na etapa anterior.
Em seguida, você precisa adicionar as seguintes informações ao formulário Inserir:
unmeta_id
: deixe esse campo em branco (ele será gerado automaticamente)user_id
: o ID de usuário usado na etapa anteriormeta_key
: deve serwp_capabilities
meta_value
: insira isto:a:1:{s:13: "administrator";s:1: "1";}
Depois disso, ao rolar a tela para baixo, você deverá encontrar campos para uma segunda linha. Você precisa adicionar as seguintes informações:
unmeta_id
: deixe esse campo em branco (ele será gerado automaticamente)user_id
: o ID de usuário que você usou nas etapas anterioresmeta_key
: você precisa inserirwp_user_level
meta_valor
: 10
Quando terminar de inserir as informações nos campos, clique no botão “Go” (Ir). Parabéns, você criou um novo nome de usuário de administrador!
Agora, você deve conseguir fazer login na área de administração do WordPress usando o nome de usuário e a senha que especificou para esse usuário.
Assim que fizer login, você precisará navegar até Usuários ” Todos os usuários e clicar no nome de usuário que acabou de criar.
Agora, sem alterar nada, role até a parte inferior da página e clique no botão “Save” (Salvar).
Isso permitirá que o WordPress limpe o usuário que você acabou de criar e adicione algumas informações extras necessárias.
Adição de um usuário administrador ao banco de dados do WordPress usando uma consulta SQL
Se você for um desenvolvedor, poderá acelerar o processo usando código.
Basta inserir essa consulta SQL em seu banco de dados:
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('3', 'demo', MD5('demo'), 'Your Name', 'test@example.com', 'http://www.example.com/', '2022-09-01 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '3', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '3', 'wp_user_level', '10');
Certifique-se de alterar “databasename” para o banco de dados com o qual está trabalhando.
Além disso, não se esqueça de alterar os outros valores para aqueles que você deseja para o novo usuário, conforme explicamos no primeiro método.
Guias de especialistas sobre o que fazer quando o administrador do WordPress está bloqueado
Agora que você sabe como adicionar um usuário administrador por meio do MySQL, talvez queira ver alguns artigos sobre como corrigir seu site quando estiver bloqueado na área de administração do WordPress.
- O que fazer quando você está bloqueado fora da administração do WordPress (wp-admin)
- Como usar o modo de recuperação do WordPress
- Como redefinir uma senha do WordPress no phpMyAdmin
- Como desbloquear o limite de tentativas de login no WordPress
- Como desativar todos os plug-ins quando não for possível acessar o WP-Admin
- Como corrigir a tela branca da morte do WordPress (passo a passo)
- Como corrigir o erro crítico no WordPress (passo a passo)
- Como corrigir o problema de atualização e redirecionamento da página de login do WordPress
- Como corrigir o erro ao estabelecer uma conexão com o banco de dados no WordPress
- Como corrigir facilmente o erro This Site Can’t Be Reached no WordPress
Esperamos que este tutorial tenha ajudado você a aprender como adicionar um usuário administrador ao banco de dados do WordPress via MySQL. Talvez você também queira ver nosso guia definitivo de segurança do WordPress ou nossa lista de erros comuns do WordPress e como corrigi-los.
Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.
zohaib
Thanks a lot, Yes I got my problem solved and this was due to the the role assigned to my user name. Cheers
Bichir Mihail
Thanks, really helpfull
Rastislav Nichta
Really very simple and clear guide to how to create a user through MYSQL Wordpress database, thank you.
Mary Janis
This info is outdated cause HG format has all changed. Where the heck is wp_user?
Susan Marshall VA
Thank you so much for this. Just had a client that locked herself out of her site and I was able to get her back in with these instructions.
Kumar Mritunjay
I’ve used this on my websites. Works like a charm…very easy to follow!
Thank you for this amazing time saver technique.
sara asadiha
i did everything u said, but it did not work what else should i do?
Peter Gough
Thanks for this. Really helped when I was locked out of Wordpress
Michael Sineni
I have changed my admin access to editor because i was trying to change role capabilities to edit gravity forms. Suddenly i no longer see edit cornerstone or have access!! HELP!
Ayesi
Really good, everything works perfect, thanks a million!!
Stella
Thanks a lot! This saved my day. Whew!
Nilo Velez
I don’t now if it is an update to WordPress data structure, but I’ve just encounter a site in which I’ve had to enter the wp_options meta_key values as:
[table_prefix]capabilities instead of wp_capabilities
[table_prefix]user_level instead of wp_user_level
I leave this here as it might be of help.
Takis Pan
You sir are awesome!
I guess it uses the database prefix but in case the site has been moved, or someone changed the prefix from “wp_” to something else, capabilities and user_level should be changed accordingly.
Abraham Quilca
Thanks, this comment helped a lot.
I had to double-check and get the exact table_prefix value from our wp-config.php file. Ours meta_key values were correct except for capitalization. I believe some hosting companies with single-click wordpress installs will set their own table_prefixes, so be sure to check for that as well.
Cheryl
this worked for me too, thank you Abraham
Loren Helgeson
I’ve used this on three different websites so far. Works like a charm!
Thank you for this amazing time saver.
Steve Day
BRILLIANT!!!
Thank you – saved my day
Kirst
It looks like there’s been a database change in the most recent version of WP, so this post may need to be updated.
I’s been an awesome resource, thank you!
Loren Helgeson
I can’t verify this with previous versions of Wordpress, but I just tested this with the latest version of Wordpress, and it worked fine for me. Can anyone also confirm if this was a fluke?
Abid
I have done same sql quires to make admin user. User created and logged but showing Sorry, you are not allowed to access this page error. Please help me about this.
Jade
THANK YOU SO MUCH! I had an issue with WooCommerce Product Vendors, where I have applied as a vendor while logged in as admin. From that point on I couldn’t log in and I was receiving a message”You will be notified once your account has been approved” O_o
Previously I had to re-install WP because of this!!! Now I found your post and it was such a help!!! Thank you so much for sharing this x
Ben
Didn’t work at all for me. I get a “ERROR: Incorrect username or password.”
Yeah yeah, I’ve check it. Password and user are correct.
So what now? I used to have admin access but now only have a lower basic level that doesn’t show the user settings.
Loren Helgeson
This worked perfectly on the past two sites I’ve had to use it on.
SHAILENDRA RAJAVARAM
Awesome….saved me tons of hardship like for other issues. I saw that for some reason all the administrators in my site became something else…
GREAT HELP !!
The guys who discussed about wp_prefixes…..perfect….
Ah !!!
Werner Ullrich
For me it is a great helpful post. I have modified this SQL script and re-animated my door to the administrator entry of my wordpress homepage. Thanks.
Werner Ullrich
Smithg0
Okay this YouTube video is much enhanced than last one, this one has pleasant picture feature as well as audio.
Jerry L
I wanted to change several “Nicename” entries to other values than that user’s Login ID. From within PhpMyAdmin, I exported the “wp_users” table.
Then I made the necessary changes in my code editor.
Then after saving a backup of the original users table and the entire database, I “Import”ed just the “wp_users” table back into the database using PhpMyAdmin.
Worked fine for me.
Brad
Worked like a charm! Thanks!
kali
I followed this and was able to login but cannot go to the dashboard. I get this error: You do not have sufficient permissions to access this page.
Oleg
I have the same issue.
Eileen
I had the same problem but in wp_usermeta where we are told to write:
meta_value – insert this: a:1:{s:13:”administrator”;s:1:”1″;}
I changed the value to:
a:1:{s:13:”administrator”;b:1;}
and it worked. I found this value in the corresponding value further up in the table for the original administrator account. Check your table and see if there are any other previous administrators, and copy the same value (just in case it differs to my value).
Mark P
This worked for me thank you!
Ardestani
It works , thank you , really thank you
Jason Coleman
This didn’t work for me
Daniel Payne
For this to work with the latest WordPress 4.4.2 I had to update the meta_key names because my WordPress install was using a table prefix of wp_brnq_ instead of the typical wp_ prefix.
Rose
What do you mean? This is no working for me either.
Robert Drummond
Thank you for this! It saved me from an errant plugin that over-wrote my admin record in the users table!
Nadia
I am currently fixing the website of my mom for her own company and I am a kind of wordpress-dummy. I couldn’t properly log in because she sent me the wrong password. After three failed attempts it said I should look in the data. Message: ‘Username or password are not correct. Please check your data.’
I followed these steps here and I followed all of these steps very precisely, but still, with my new username and password, I am unable to log in. My prefix was different than wp_ what this article stated, so I changed the prefix as well – but can’t come through. Now I am locked out until tomorrow.
What happened, can someone maybe help me / explain me what I did wrong and how can I fix this. I really promised my mom to build her website, and it needs to be updated really soon!
Joe Harkins
you were doing a great job of step by step until you got to
“meta_key – this should be wp_capabilities”
What does “should be” mean in this context? Does it mean that it should already say that that in that field, perhaps generated from something prior? If is not there what is required?
There’s a drop down field to the right of meta_key. That file name “wp_capabilities” does not exist as a selection. There’s a blank field to the right of that. Do I paste wp_capabilities into it? Is there a value of that name somewhere that I should be putting in that field?
And I see more trouble ahead. You say “insert another row.”
I take the word insert as a verb. Where and how do I do that? I am already on the Insert page. There is nothing on it says “Insert new row.”
Looking further down – all the way at thre bottom – skipping over the next section (which I an told to do) I see a field that says “Insert as a new row.”
But “insert a new row” and being told to go to a field that contains the phrase “Inert as a new row” are not all the same thing.
and there is a checked box that says “ignore” right above it. What’s the point of going further if that box is still checked ignore – and is “insert a new row” the same as “insert a new row?”
And I see the same “should be” confusion ahead again in the next set of instructions.
But I’m stuck back the first “should” because I am literal minded. Please clarify?
Jeff
Hi Joe,
“meta_key – this should be wp_capabilities” means that the meta_key value (the textbox in phpmyadmin) should be wp_capabilities
When he refers to inserting a new row, you can do so by clicking insert from the navigation at the top of phpmyadmin this tutorial assumes you have already done the first insert and are on the browse tab.
Rich
I had a multiple site setup. After doing this I can access both sites, however I have no Network Admin capability and not Plugin management… Under “My Sites” I see my two sites, but no “Network” option. On the vertical menu area for my site I seem to have everything other than “Plugins.”
Seems I do not have Administration over my WP Network for multiple sites?
sapere aude
that was awesome! thanks.
Bouasone
Many thank it very helpful
Russ
Thanks for the great tutorial! I was able to successfully log in.
Arpan Das
Thanks a lot. Working fine…
Rodolfo
This saved my life today – thank you!
Phil
This worked for me with the following modification: the wp_capabilities value had to be taken from another admin users row because it had additional permissions or whatever those are. copy the values in that case from an existing user if necessary
Reid Walley
If you’ve gone through all of the steps and you’re STILL getting the “You do not have sufficient permissions to access this page” error message when trying to log in…
I had to replace the first example meta_key (wp_capabilities) with my own prefix: change wp_capabilities to whateveryourprefixis_capabilities
Same with the second meta_key example (wp_user_level). I changed it to my specific prefix: change wp_user_level to whateveryourprefixis_user_level
Yoana
Thanks, that fixed it
Terry Hale
Such a helpful article. Perfectly done, easy to understand. Thanks for the time you spent putting it together.
Andre
This has been very helpful for me on several occasions. Thank you for putting this together!!!
2046
for those who still got the You do not have sufficient permissions to access this page.
you might want to check that the wp_capabilities adn stuff follows your db prefix name..
like if your normally wp_usersmeta has blab787_usersmeta the wp_capabilities will be blab787_capabilities etc.
Lydia B
Thank you, your solution to the “you do not have sufficient permissions” error message worked perfectly for me.
Terry Hale
Thanks for posting! I ran into that problem, and you solved it.
Cristian Deraco
Thank you !!! it worked for me yeah!
Rony
I can not see the table with user infomations, have any idea?
Denny
Fantastic walk-through. This is spot on with multiple versions of phpmyadmin so ignore the differences in the screenshots. Thanks for the write-up!
-D
Denny
WordPress 3.6.1. I will test this with 4 and confirm as well.
Ludwik C. Siadlak
Same here, in September 2015 I get “You do not have sufficient permissions to access this page.” error after using the SQL code provided. Which is strange, since this article is only 6 months old!
Harm
I followed your instructions to the letter but something went wrong (don’t know what) and now I don’t have access to my website. I get the message: database error.
Can I undo the changes I made? Please help.
Kiel
all I had to do was revert the meta data back to admin and it worked great. Thanks for the article.
Matthew Galvin
Pretty much useless in > version 3. Nice start tho.
Chris Hewlett
Hello, I dug a little deeper into the problem and found that existing entries in the “usermeta” table had a prefix that was unique to my site. My wordpress tables all begin with ar_, and once I edited those 2 rows to reflect that, my login was complete, with all priveleges.
Regards,
Chris
Chris Hewlett
Hello, and thank you for the above write-up on this subject. I have been locked out of my local site (XAMPP) and other articles I have read deal with changing the existing admin user password using phpMyAdmin. I did not have success with those methods.
I followed your instructions above and the login screen did accept the credentials.
Unfortunately I was redirected to domain//wp-admin/profile.php and the phrase “You do not have sufficient permissions to access this page”.
From the front end of the site, I can see I am logged in but when I click on Dashboard, the same phrase appears.
Do you have any suggestions that would allow me access?
Thanks in advance,
Chris
Abishai
Hi, tried the fix by following it to the “T” yet when I try logging in: url/wp-admin takes me to a url/25/ page as before. Wonder what I did wrong. Please advice. Thanks in advance.