SQL User DB Management
From Kb
To add a user and a database do this and then flush the tables or do a mysqladmin reload.
db table
insert into db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Index_priv, Alter_priv) values ('localhost', 'database', 'user', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y','Y');
user table
insert into user (Host, User, Password) values ('localhost', 'user', password('a1b2c3'));
Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='youruser'; FLUSH PRIVILEGES;
The quick way to do it:
GRANT ALL ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password';
The GRANT command creates the entries in user and db tables for you.
Adding an admin user to a database via the CLI
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `user_registered`) VALUES ('newadmin', MD5('pass123'), 'firstname lastname', 'email@example.com', '0', '2017-04-03 15:54:00'); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');