Guest User

Untitled

a guest
Jan 25th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. $this->mysqli = new mysqli('localhost', $admin_account, $password);
  2.  
  3. $setup = [
  4. /* create database */
  5. sprintf('CREATE DATABASE IF NOT EXISTS %s;', $dbName),
  6. /* grant admin */
  7. sprintf("GRANT ALL PRIVILEGES ON %s.* TO '%s'@'%s' WITH GRANT OPTION;", $dbName, $admin_account, $admins_remote_ip),
  8. /* add user */
  9. sprintf("CREATE USER '%s'@'localhost' IDENTIFIED BY '%s';", $dbUsername, $dbPassword),
  10. /* THIS WAS ADDED AS A FIX TO NO AVAIL */
  11. sprintf("UPDATE mysql.user SET password=PASSWORD('%s') WHERE user='%s'", $dbPassword, $dbUsername),
  12. /* grant retailer*/
  13. sprintf("GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost';", $dbName, $dbUsername),
  14. /* flush */
  15. "FLUSH PRIVILEGES;",
  16. ];
  17.  
  18.  
  19. $this->mysqli->begin_transaction();
  20.  
  21. foreach ($setup as $query) {
  22. if (false == $this->mysqli->query($query)) {
  23. $error = $this->mysqli->error;
  24. $this->mysqli->rollback();
  25. return $error;
  26. }
  27. }
  28.  
  29. $this->mysqli->commit();
  30.  
  31. > mysql -u admin_account -p
  32. update mysql.user set password=PASSWORD('dbPassword') where user='dbUsername';
Add Comment
Please, Sign In to add comment