FreeBSD manual
download PDF document: mysql_change_user.3.pdf
mysql_change_user(3) MariaDB Connector/C mysql_change_user(3)
Name
mysql_change_user - changes user and default database
Synopsis
#include <mysql.h>
my_bool mysql_change_user(MYSQL * mysql,
const char * user,
const char * passwd,
const char * db);
Description
Changes the user and default database of the current connection.
In order to successfully change users a valid username and password
parameters must be provided and that user must have sufficient
permissions to access the desired database. If for any reason
authorization fails, the current user authentication will remain.
Parameters
o mysql is a connection identifier, which was previously allocated by
mysql_init(3) and connected by mysql_real_connect(3).
o user - the user name for server authentication
o passwd - the password for server authentication
o db - the default database. If desired, the NULL value may be passed
resulting in only changing the user and not selecting a database. To
select a database in this case use the mysql_select_db(3) function.
Notes
o mysql_change_user will always cause the current database connection
to behave as if was a completely new database connection, regardless
of if the operation was completed successfully. This reset includes
performing a rollback on any active transactions, closing all
temporary tables, and unlocking all locked tables.
o To prevent denial of service and brute-force attacks the server will
block the connection if mysql_change_user() failed three times in a
row
Return value
Returns zero on success, nonzero if an error occurred.
See also
o mysql_real_connect(3)
o mysql_select_db(3)
Version 3.3.1 mysql_change_user(3)