Add an Admin User to the WordPress Database via MariaDB
- Category: 電腦相關
- Last Updated: Monday, 01 May 2017 23:30
- Published: Monday, 01 May 2017 23:14
- Written by sam
為了要測試搬移的網站是否成功並檢查在WP的Admin後臺是否正常
手邊又沒有原始的帳、密,改又不方便
只好自己新增一下帳戶
先登入
mysql -uroot -p
再新增自己的帳號進去(記得依現有環境替換值)
INSERT INTO `YourDB`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('2', 'sam', MD5('PW'), 'sam', 'This email address is being protected from spambots. You need JavaScript enabled to view it.', 'http://boredom.gotdns.com/', '2011-06-07 00:00:00', '', '0', 'sam');
INSERT INTO `YourDB
`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '2', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `YourDB
`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '2', 'wp_user_level', '10');