summaryrefslogtreecommitdiffstats
path: root/libmariadb/man/mysql_change_user.3
blob: 8f9939b8cb10c91f96e891852236739b40edc9f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.\" Automatically generated by Pandoc 2.5
.\"
.TH "mysql_change_user" "3" "" "Version 3.3.1" "MariaDB Connector/C"
.hy
.SS Name
.PP
mysql_change_user \- changes user and default database
.SS Synopsis
.IP
.nf
\f[C]
#include <mysql.h>

my_bool mysql_change_user(MYSQL * mysql,
                          const char * user,
                          const char * passwd,
                          const char * db);
\f[R]
.fi
.SS Description
.PP
Changes the user and default database of the current connection.
.PP
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.
.SS Parameters
.IP \[bu] 2
\f[C]mysql\f[R] is a connection identifier, which was previously
allocated by \f[B]mysql_init(3)\f[R] and connected by
\f[B]mysql_real_connect(3)\f[R].
.IP \[bu] 2
\f[C]user\f[R] \- the user name for server authentication
.IP \[bu] 2
\f[C]passwd\f[R] \- the password for server authentication
.IP \[bu] 2
\f[C]db\f[R] \- 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 \f[B]mysql_select_db(3)\f[R]
function.
.SS Notes
.IP \[bu] 2
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.
.IP \[bu] 2
To prevent denial of service and brute\-force attacks the server will
block the connection if \f[C]mysql_change_user()\f[R] failed three times
in a row
.SS Return value
.PP
Returns zero on success, nonzero if an error occurred.
.SS See also
.IP \[bu] 2
\f[B]mysql_real_connect(3)\f[R]
.IP \[bu] 2
\f[B]mysql_select_db(3)\f[R]