I am trying to create a db user and assigned him to the new database what already has been created using dbforge library:
$this->dbforge->create_database( $oData->db_name );
My question is:
- What must do first - create user or create a database?
- How to assign user to current database and add grant privileges?
My code to create a database and user:
$this->load->dbforge();
// create user
$this->db->query("CREATE USER '". $data->db_user ."'@'localhost' IDENTIFIED BY '". $data->db_password ."';");
// create database
$this->dbforge->create_database( $data->db_name );