Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->mysqli = new mysqli('localhost', $admin_account, $password);
- $setup = [
- /* create database */
- sprintf('CREATE DATABASE IF NOT EXISTS %s;', $dbName),
- /* grant admin */
- sprintf("GRANT ALL PRIVILEGES ON %s.* TO '%s'@'%s' WITH GRANT OPTION;", $dbName, $admin_account, $admins_remote_ip),
- /* add user */
- sprintf("CREATE USER '%s'@'localhost' IDENTIFIED BY '%s';", $dbUsername, $dbPassword),
- /* THIS WAS ADDED AS A FIX TO NO AVAIL */
- sprintf("UPDATE mysql.user SET password=PASSWORD('%s') WHERE user='%s'", $dbPassword, $dbUsername),
- /* grant retailer*/
- sprintf("GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost';", $dbName, $dbUsername),
- /* flush */
- "FLUSH PRIVILEGES;",
- ];
- $this->mysqli->begin_transaction();
- foreach ($setup as $query) {
- if (false == $this->mysqli->query($query)) {
- $error = $this->mysqli->error;
- $this->mysqli->rollback();
- return $error;
- }
- }
- $this->mysqli->commit();
- > mysql -u admin_account -p
- update mysql.user set password=PASSWORD('dbPassword') where user='dbUsername';
Add Comment
Please, Sign In to add comment