Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Hinzufügen eines Admin-Benutzers zur WordPress-Datenbank über MySQL

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

Haben Sie sich von Ihrer WordPress-Website ausgesperrt?

Manchmal sperren Hacker Sie von Ihrer eigenen Website aus, indem sie Ihr Administratorkonto aus der Datenbank löschen.

In diesem Artikel zeigen wir Ihnen, wie Sie der WordPress-Datenbank über MySQL einen Admin-Benutzer hinzufügen können, damit Sie Ihren Zugang zurückbekommen.

How to Add an Admin User to the WordPress Database via MySQL

Warum einen Admin-Benutzer über MySQL zur WordPress-Datenbank hinzufügen?

Wir sind einmal auf ein Problem gestoßen, bei dem die Website eines Benutzers gehackt wurde und sein Administratorkonto aus der Datenbank gelöscht wurde. Dadurch wurde er von seiner WordPress-Website ausgesperrt.

Wir konnten ihnen helfen, Zugang zu ihrer Website zu erhalten, indem wir einen neuen Administrator-Benutzer direkt auf der WordPress-Website anlegten. Dazu verwendeten wir phpMyAdmin, ein webbasiertes Tool, mit dem Sie MySQL-Datenbanken über Ihren Webbrowser verwalten können.

Wenn Sie sich aufgrund von Hackern oder weil Sie Ihr Passwort vergessen haben, aus Ihrem WordPress-Administrationsbereich ausgesperrt haben, können Sie dies ebenfalls tun.

Sie sollten jedoch immer eine Sicherungskopie Ihrer Datenbank erstellen, bevor Sie irgendwelche MySQL-Bearbeitungen vornehmen. Sobald Sie sich wieder in Ihre Website einloggen können, sollten Sie unseren Leitfaden für Anfänger befolgen, um Ihre gehackte WordPress-Website zu reparieren.

Schauen wir uns also an, wie man einen Admin-Benutzer über MySQL zur WordPress-Datenbank hinzufügt.

Hinzufügen eines Admin-Benutzers zur WordPress-Datenbank mit phpMyAdmin

phpMyAdmin ist bei den meisten führenden WordPress-Hosting-Unternehmen vorinstalliert. Sie finden es im cPanel-Dashboard Ihres Hosting-Kontos im Bereich Datenbanken.

Hier ist ein Screenshot aus dem Bluehost-Kontrollzentrum:

Selecting phpMyAdmin on cPanel

Wenn Sie auf das Symbol klicken, öffnet sich die phpMyAdmin-Oberfläche. Sie müssen Ihre WordPress-Datenbank in der linken Spalte auswählen.

Danach zeigt phpMyAdmin alle Tabellen in Ihrer WordPress-Datenbank an. Sie werden Änderungen an den Tabellen wp_users und wp_usermeta vornehmen.

You Will Be Making Changes to the wp_users and wp_usermeta Tables

Hinzufügen eines Benutzers zur Tabelle wp_users

Zunächst müssen Sie die Tabelle wp_users finden und anklicken. Daraufhin werden die derzeit in der Tabelle aufgeführten Benutzer angezeigt.

Im Screenshot unten sehen Sie, dass es zwei Benutzer-IDs in der Tabelle unserer Demo-Website gibt, 1 und 2. Wenn wir einen neuen Benutzer für unsere Demo-Website anlegen, muss diese ID eindeutig sein, also geben wir die Nummer 3 ein.

Klicken Sie auf die Registerkarte „Einfügen“ am oberen Rand des Bildschirms, damit Sie die Informationen für einen neuen Verwaltungsbenutzer eingeben können.

Click the Insert Tab

Fügen Sie die folgenden Informationen in die Felder des Formulars „Einfügen“ ein:

  • ID: Wählen Sie eine eindeutige Nummer (in unserem Beispiel verwenden wir 3)
  • user_login: der Benutzername, der beim Einloggen verwendet wird
  • user_pass: Fügen Sie ein Passwort hinzu und stellen Sie sicher, dass Sie MD5 im Funktionsmenü auswählen (siehe Screenshot unten)
  • user_nicename: der vollständige Name oder Spitzname des Benutzers
  • user_email: die E-Mail-Adresse des Benutzers
  • user_url: Ihre Website-Adresse
  • user_registered: Wählen Sie das Datum und die Uhrzeit der Registrierung des Benutzers über den Kalender aus.
  • user_activation_key: leer lassen
  • user_status: setzen Sie diesen Wert auf 0
  • display_name: der vollständige Name des Benutzers oder sein Anzeigename
Fill In the Fields for the New User

Wenn Sie fertig sind, klicken Sie auf die Schaltfläche „Go“, um den neuen Benutzer zu speichern.

Hinzufügen eines Benutzers zur wp_usermeta-Tabelle

Jetzt müssen Sie die Tabelle wp_usermeta finden und anklicken. Danach sollten Sie auf die Registerkarte „Einfügen“ klicken, wie Sie es im vorherigen Schritt getan haben.

Als Nächstes müssen Sie die folgenden Informationen in das Formular „Einfügen“ eingeben:

  • unmeta_id: leer lassen (sie wird automatisch generiert)
  • user_id: die Benutzer-ID, die Sie im vorherigen Schritt verwendet haben
  • meta_key: dies sollte wp_capabilities sein
  • meta_value: insert this: a:1:{s:13: "administrator";s:1: "1";}
Fill In the Fields for the New User

Wenn Sie dann nach unten scrollen, sollten Sie Felder für eine zweite Zeile finden. Sie müssen die folgenden Informationen hinzufügen:

  • unmeta_id: leer lassen (sie wird automatisch generiert)
  • user_id: die Benutzer-ID, die Sie in den vorherigen Schritten verwendet haben
  • meta_key: Sie müssen wp_user_level eingeben
  • meta_wert: 10
Fill In the Fields for the New User

Wenn Sie alle Informationen in die Felder eingegeben haben, müssen Sie auf die Schaltfläche „Go“ klicken. Herzlichen Glückwunsch, Sie haben einen neuen Administrator-Benutzernamen erstellt!

Jetzt sollten Sie in der Lage sein, sich mit dem Benutzernamen und dem Passwort, die Sie für diesen Benutzer angegeben haben, in Ihrem WordPress-Administrationsbereich anzumelden.

Sobald Sie sich angemeldet haben, müssen Sie zu Benutzer “ Alle Benutzer navigieren und dann auf den gerade erstellten Benutzernamen klicken.

Navigate to Users » All Users and Edit the New User

Blättern Sie nun, ohne etwas zu ändern, zum Ende der Seite und klicken Sie auf die Schaltfläche „Speichern“.

Dadurch kann WordPress den soeben erstellten Benutzer bereinigen und einige zusätzliche Informationen hinzufügen, die erforderlich sind.

Hinzufügen eines Admin-Benutzers zur WordPress-Datenbank mithilfe einer SQL-Abfrage

Wenn Sie ein Entwickler sind, können Sie den Prozess mit Code beschleunigen.

Legen Sie diese SQL-Abfrage einfach in Ihrer Datenbank ab:

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');

Stellen Sie sicher, dass Sie „databasename“ in die Datenbank ändern, mit der Sie arbeiten.

Vergessen Sie auch nicht, die anderen Werte so zu ändern, wie Sie es für den neuen Benutzer wünschen, wie wir es in der ersten Methode erklärt haben.

Drop This SQL Query Into Your Database

Expertenratschläge, was zu tun ist, wenn man aus dem WordPress-Admin ausgesperrt ist

Da Sie nun wissen, wie Sie einen Admin-Benutzer über MySQL hinzufügen können, möchten Sie vielleicht einige Artikel darüber lesen, wie Sie Ihre Website reparieren können, wenn Sie aus dem WordPress-Administrationsbereich ausgesperrt sind.

Wir hoffen, dass dieses Tutorial Ihnen geholfen hat, zu lernen, wie man einen Admin-Benutzer zur WordPress-Datenbank über MySQL hinzufügt. Vielleicht interessieren Sie sich auch für unseren ultimativen WordPress-Sicherheitsleitfaden oder unsere Liste der häufigsten WordPress-Fehler und deren Behebung.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

237 KommentareEine Antwort hinterlassen

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Max Johnson says

    The user is inserted. The site accepts the credentials

    but

    site does not allow use of admin panel: /wp-admin

    „Sorry, you are not allowed to access this page.“

    This is WordPress 6.4.2 & PHP 8.2

  3. Navin Rangar says

    It’s not working for me, sadly. I’ve checked and everything is showing in the database tables, but the website says the email address is not registered. If I try username it says it’s not recognised. Any ideas would be gratefully received!

    • WPBeginner Support says

      You may want to check that you do not have multiple databases in the chance that a placeholder site was set up when you first signed up with your hosting provider.

      Admin

    • WPBeginner Support says

      For editor users, we would recommend manually creating them through the WordPress interface using an admin account.

      Admin

  4. perceval hasselman says

    I am so happy for your explanation. This saves me a lot of work.

    It was hard to do without knowledge but this tutorial did it for me

    Thanks a lot!

  5. Eleanor says

    It’s not working for me, sadly. I’ve checked and everything is showing in the database tables, but the website says the email address is not registered. If I try username it says it’s not recognised. Any ideas would be gratefully received!

  6. newbie says

    Hi there,
    I’m trying to move my live wordpress site to my local server because I need to do an updates.
    However after setting up in the local server I’m not able to login and I came accross this article
    ‚Adding an Admin User to the WordPress Database Using a SQL Query‘. My questions is the adding of this user should be done in the live server or my local server.
    Thank you.

  7. MKallas says

    Thank you. This might come handy in other cases too… I made a Local AMPPS WordPress Install and for some reason first registrant got Subscriber rights instead of Admin. Really interesting. Anyways, PhpMyAdmin and fix of wp_usermeta -> wp_usercapabilities -> „a:1:{s:13:“administrator“;s:1:“1″;}“ sorted it out.

  8. Andy says

    Hi, thanks for the info. I’ve only been able to login as a general ‚User‘ using this method – I can’t see/access the Admin Dashboard. The site is a directory site that i migrated from a backup to a new domain. Any suggestions to get full admin privileges?

  9. B A says

    I come here 2-3 times a year to get that nice set of SQL boilerplate. Should probably just save it to my notes at this point. Thanks so much!

  10. Jana says

    Thank you so much for this post! I had so many problems after migrating and changing the base url of my site and this post solved them all.

  11. Kristen says

    I followed these steps and see my new account, but my site still will not allow me to log in. It says invalid user, then if I try resetting the password it says no account exists. What’s my next step to fix this?

    • WPBeginner Support says

      You may want to ensure you added the user to the correct database, you should also be able to reach out to your hosting provider for them to take a look.

      Admin

  12. Stefan Pl says

    1. Please change the post to include information about table prefixes – a problem that appeared quite a few times in the comments and will keep you from succeeding if you just follow the post and have an alternative prefix.
    2. Thanks for the information presented here :-)

  13. Mandy says

    For everyone who can login but not see the wp-admin, these instructions aren’t wholly correct.
    The wp_cabailities meta_value actually needs to be set as a:1:{s:13:“administrator“;b:1;}
    Otherwise your user doesn’t end up with a role set and you can’t see wp-admin.

  14. Cristina says

    Hi. My WordPress website is being managed by a remote developer. He is an admin and so am I. We have a monthly agreement and I have every intention of paying him his dues. What measures can I do to make sure that I keep the access as well as my website should things go sideways? Can you please help me? Thanks in advance.

    • WPBeginner Support says

      Create backups of your site and as long as you are the one paying for hosting you can restore the site

      Admin

  15. Janne says

    Hi,
    Thanks for writing this! I see I am not the only one who was looking for instructions. My user was created, and I can click on the „Reset password“ link and also get an e-mail from the system, but I am not able to log in. I saw that my „usermeta“ table looks different from the other users‘ – mine starts with „closedpostboxes_attachment“, not „first_name“ etc. What might be the reason for that?
    j

    • WPBeginner Support says

      That table is for meta boxes that you have closed, the order you’re seeing the table shouldn’t cause an issue

      Admin

  16. Sofia says

    Hi!
    I did all the process but when I log in to the dashboard I only see the „Welcome to WordPress“ section, I don’t see anything else in the admin area.

    Please, can you help me?

    • WPBeginner Support says

      Your hosting provider may have customized their login area, there is normally an advanced section you can go to or reach out to your host and they should be able to assist :)

      Admin

  17. Glenn Gordon says

    I have a WP blog site which I have been locked out of. I created a new admin and can log in, but not to my dashboard. Instead, I go to my main blog page with my name and admin # at the top right and a logout button. How do I gain access to my admin/dashboard area?

  18. João says

    Hello,
    Well, this is embarrassing but… would anyone be able and kind enough to help me solve the father of problems? – wp_users table gone/missing… :(
    Thank you in advance.

    • WPBeginner Support says

      You would want to reach out to your hosting provider if that table is not with your database to see if they have a backup of your database to restore.

      Admin

  19. lhoucine says

    hi! thank you for your tutorials,
    i did all these steps and my issue still the same, when I want to login to my wp-admin, show me this message „Sorry, you are not allowed to access this page.“ please if know how to fix this I will so thankful
    thank you

  20. Holly Fitzgerald says

    After backing up my database with updraftPlus, then restoring it, we lost all admin access. I followed these instructions but am still getting an error saying I do not have access. Help!

  21. john juncal says

    you are an absolute legend! after3 hours of trying useless suggestion from forums, you came up trumps, thank you!

  22. Taieuro says

    Thanks your information!
    But after inserting a admin accout, i can not login my site.
    Appear „Protection“ button stop me to login WP dashboard.
    Please help me!

  23. Matthew says

    Didn’t work, I’m getting the „Sorry, you are not allowed to access this page.“ message. I checked my wp-config.php and the prefix is „wp_“ but it still doesn’t work. Any ideas?

  24. UgoChukwu Agbams says

    Thank you very much. This article really helped me a lot, after my admin account was set to customer by a plugin I set to change user role from whatever to customer when they made a purchase.
    I never knew it will affect the admin role as well.

  25. kerry says

    is there a common reason why user can login but Dashboard is not made available? I see a lot of meta key values in the db

  26. PM says

    Thank you sooooo much for this. Just this morning my wordpress site was hacked and I could not login into wp-admin. It was giving „user not found“ error. I used this to fix things in my hostgator account.
    Very very grateful. Written instructions are excellent but the video could be slower with more details.

    • Anup Poudel says

      It is simple mate.See what is written in you database name.
      Like in my case it was wprn_capabilities,wprn_user_level..

  27. Shaheen says

    I messed around with this more; watched the video several times and it’s still not working.

    In my case, I lost admin access after I migrated my WP site from one hosting account to another.

    my old admin login is able to login but once in, isn’t able to do anything.

    Using mysql, i tried creating a new user and adding the meta data. When I try to login with the new user, it says the password is incorrect. I tried saying „forgot password“ and I did not receive any email to the email address i included when making the user with msql.

    In mysql i can see my old admin user is still there. I tried adding meta data to give admin privledges to that user, by putting in the corresponding userID. This didn’t change anything. I am still able to login with that user but don’t have access to anything. If anyone has any advice it would be much appreciated!

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.