Next: Communication with the MySQL
Up: The MySQL process
Previous: Signature
Contents
Subsections
This call will make a process for connecting with a MySQL server.
- The value of host may be either a hostname or an IP address. If host is "" or the string "localhost", a connection to the local host is assumed. If the OS supports sockets, they are used instead of TCP/IP to connect to the server.
- The user parameter contains the user's MySQL login ID. If user is the empty string "", the current user is assumed. Under Unix, this is the current login name.
- The passwd parameter contains the password for user. If passwd is "", only entries in the user table for the user that have a blank (empty) password field are checked for a match. This allows the database administrator to set up the MySQL privilege system in such a way that users get different privileges depending on whether they have specified a password.
Do not attempt to encrypt the password. Password encryption is handled automatically by the C client API.
- db is the database name. If db is not "", the connection sets the default database to this value.
- If port is not 0, the value is used as the port number for the TCP/IP connection. Note that the host parameter determines the type of the connection.
- If socket is not "", the string specifies the socket or named pipe that should be used. Note that the host parameter determines the type of the connection.
Once the process is created it will try to make a connection to the server. It will then send a message to the out channel indicating that it is ready to accept commands (see below). Subsequent communication with the process will be done by issuing commands on the in channel. Every command will cause one or more answers to be sent on the out channel. The process will not terminate until it receives a quit message, the only exception to this is noted below under "Errors".
Once the process is created, it is not possible to change the connection, user etc. unless it can be done via. SQL queries.
If the process successfully connects to the server it will send the message connected to the out channel.
- If the C client API fails to allocate memory for the connection, the process will send the message initialisation.error to the out channel. Following this, it will send the message quit and then terminate. In all other cases the process must be explicitly killed with the quit command. This error should rarely occur.
- If the process fails to connect to the MySQL server, it will send a mysql.error; INT; MOBILE []BYTE message containing the error number and description (for information on how to interpret the error numbers, see the MySQL documentation). It will remain alive, but every other commmand than reconnect and quit will result in an error message.
Next: Communication with the MySQL
Up: The MySQL process
Previous: Signature
Contents
Espen Suenson
2006-07-07