MySQLi - Change User



Syntax

change_user ( string $user , string $password , string $database )

Definition and Usage

It used to turn on or off auto-committing database modifications operation.

Example

Try out following example −

<?php
   $servername = "localhost:3306";
   $username = "root";
   $password = "";
   $dbname = "TUTORIALS";
   $conn = new mysqli($servername, $username, $password, $dbname);
   
   if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
   } 
   echo"Database connected \n";
   mysqli_change_user($conn, "user", "pass", "my_NewUser"); 
   
   mysqli_close($conn);
?>

The sample output of the above code should be like this -

Database connected
mysqli_useful_functions.htm
Advertisements