Name

mysql_real_connect —

Synopsis

MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
                          const char *passwd, const char *db, uint port,
                          const char *unix_socket, uint client_flag)

Creates a connection with a MySQL database server. There are eight arguments to this function:

  • An initialized MYSQL structure, created with mysql_init.

  • The hostname or IP address of the MySQL database server (use an empty string or localhost to connect to the local MySQL server over a Unix socket).

  • The username used to connect to the database server (an empty string indicates that the Unix login name of the person running the client should be used).

  • The password used to authenticate the given user. If an empty string is used, only users with no passwords are checked for authentication. That is, if a user happened to have a password set to an empty string, he would never be authenticated.

  • The initial database selected when you connect (an empty string indicates that no database should be selected).

  • The port used to remotely connect to a MySQL database server over TCP. (0 may be used to accept the default port).

  • The filename of the Unix socket used to connect to a MySQL server on the local machine (an empty string may be used to accept the default socket).

  • Zero or more of a set of flags used under special circumstances:

    CLIENT_FOUND_ROWS

    When using queries that change tables, returns the number of rows found in the table, not the number of rows affected.

    CLIENT_IGNORE_SPACE

    Allows ...

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.