成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

MySQL數據庫中MySQL_real_connect的基本設置

數據庫 MySQL
我們今天主要向大家介紹的是MySQL數據庫中的MySQL_real_connect 連接參數的基本設置步驟,以及在實際操作中我們大家應注意的事項的描述。

此文章主要向大家講述的是MySQL數據庫中的MySQL_real_connect 連接參數的基本設置,我們在前一篇文章講述關于進行MySQL(和PHP搭配之***組合)源程序代碼的編譯鏈接,但是沒有講述運行情況,在按照上一篇文章代碼下進行編譯運行后。

發現無法鏈接數據庫文件,顯然是在MySQL(和PHP搭配之***組合)_real_connect()函數中出現了問題。在MySQL(和PHP搭配之***組合)的英文手冊中找到關于MySQL(和PHP搭配之***組合)_real_connect()的如下描述:

函數原型描述 MySQL數據庫*MySQL(和PHP搭配之***組合)_real_connect(MySQL(和PHP搭配之***組合) *MySQL(和PHP搭配之***組合), const char *host, const char

  1. *user,   
  2. const char *passwd, const char *db, unsigned int port, const char *unix_socket,   
  3. unsigned long client_flag)  
  4. Description  
  5. MySQL(和PHP搭配之***組合)_real_connect() attempts to establish a connection to a MySQL(和PHP搭配之***組合) database engine   
  6. running on host. MySQL(和PHP搭配之***組合)_real_connect() must complete successfully before you can   
  7. execute any other API functions that require a valid MySQL(和PHP搭配之***組合) connection handle structure.  
  8. The parameters are specified as follows:  
  9. *  
  10. The first parameter should be the address of an existing MySQL(和PHP搭配之***組合) structure. Before  
  11. calling MySQL(和PHP搭配之***組合)_real_connect() you must call MySQL(和PHP搭配之***組合)_init() to initialize the MySQL(和PHP搭配之***組合)   
  12. structure. You can change a lot of connect options with the MySQL(和PHP搭配之***組合)_options() call.   
  13. See Section 17.2.3.47, Â“MySQL(和PHP搭配之***組合)_options()”.  
  14. *  
  15. The value of host may be either a hostname or an IP address. If host is NULL or the   
  16. string "localhost", a connection to the local host is assumed. If the OS supports sockets   
  17. (Unix) or named pipes (Windows), they are used instead of TCP/IP to connect to the server.  
  18. *  
  19. The user parameter contains the user's MySQL(和PHP搭配之***組合) login ID. If user is NULL or the empty   
  20. string "", the current user is assumed. Under Unix, this is the current login name. Under  
  21. Windows ODBC, the current username must be specified explicitly. See Section 18.1.9.2,  
  22. “Configuring a MyODBC DSN on Windows”.  
  23. *  
  24. The passwd parameter contains the password for user. If passwd is NULL, only entries  
  25. in the user table for the user that have a blank (empty) password field are checked for a   
  26. match. This allows the database administrator to set up the MySQL(和PHP搭配之***組合) privilege system in   
  27. such a way that users get different privileges depending on whether they have specified   
  28. a password.  
  29. Note: Do not attempt to encrypt the password before calling MySQL(和PHP搭配之***組合)_real_connect();  
  30. password encryption is handled automatically by the client API.  
  31. *  
  32. db is the database name. If db is not NULL, the connection sets the default database   
  33. to this value.  
  34. *  
  35. If port is not 0, the value is used as the port number for the TCP/IP connection. Note   
  36. that the host parameter determines the type of the connection.  
  37. *  
  38. If unix_socket is not NULL, the string specifies the socket or named pipe that should  
  39. be used. Note that the host parameter determines the type of the connection.  
  40. *  
  41. The value of client_flag is usually 0, but can be set to a combination of the following   
  42. flags to enable certain features:  

 

上面描述了五個參數的主要取值,MySQL數據庫 *為MySQL(和PHP搭配之***組合)_init函數返回的指針,host為null或 // localhost時鏈接的是本地的計算機,當MySQL(和PHP搭配之***組合)默認安裝在unix(或類unix)系統中,root賬戶是沒// 有密碼的,因此用戶名使用root,密碼為null,當db為空的時候,函數鏈接到默認數據庫,在進行 // MySQL(和PHP搭配之***組合)安裝時會存在默認的test數據庫,因此此處可以使用test數據庫名稱,port端口為0,使用 // unix連接方式,unix_socket為null時,表明不使用socket或管道機制,***一個參數經常設置為0

 

  1. Flag Name Flag Description  
  2. CLIENT_COMPRESS Use compression protocol.  
  3. CLIENT_FOUND_ROWS Return the number of found (matched) rows, not the number of  
  4. changed rows.  
  5. CLIENT_IGNORE_SPACE Allow spaces after function names. Makes all functions names   
  6. reserved words.  
  7. CLIENT_INTERACTIVE Allow interactive_timeout seconds (instead of wait_timeout   
  8. seconds) of inactivity before closing the connection. The client's session wait_timeout   
  9. variable is set to the value of the session interactive_timeout variable.  
  10. CLIENT_LOCAL_FILES Enable LOAD DATA LOCAL handling.  
  11. CLIENT_MULTI_STATEMENTS Tell the server that the client may send multiple   
  12. statements in a single string (separated by Â‘;Â’). If this flag is not set,   
  13. multiple-statement execution is disabled. Added in MySQL(和PHP搭配之***組合) 4.1.  
  14. CLIENT_MULTI_RESULTS Tell the server that the client can handle multiple result   
  15. sets from multiple-statement executions or stored procedures. This is automatically   
  16. set if CLIENT_MULTI_STATEMENTS is set. Added in MySQL(和PHP搭配之***組合) 4.1.  
  17. CLIENT_NO_SCHEMA Don't allow the db_name.tbl_name.col_name syntax. This is for   
  18. ODBC. It causes the parser to generate an error if you use that syntax, which is useful  
  19. for trapping bugs in some ODBC programs.  
  20. CLIENT_ODBC The client is an ODBC client. This changes MySQL(和PHP搭配之***組合)d to be more  
  21. ODBC-friendly.  
  22. CLIENT_SSL Use SSL (encrypted protocol). This option should not be set by   
  23. application programs; it is set internally in the client library. Instead, use   
  24. MySQL(和PHP搭配之***組合)_ssl_set() before calling MySQL(和PHP搭配之***組合)_real_connect().  
  25. For some parameters, it is possible to have the value taken from an option file rather   
  26. than from an explicit value in the MySQL(和PHP搭配之***組合)_real_connect() call. To do this, call   
  27. MySQL(和PHP搭配之***組合)_options() with the MySQL(和PHP搭配之***組合)_READ_DEFAULT_FILE or MySQL(和PHP搭配之***組合)_READ_DEFAULT_GROUP option   
  28. before calling MySQL(和PHP搭配之***組合)_real_connect(). Then, in the MySQL(和PHP搭配之***組合)_real_connect() call, specify   
  29. the Â“no-value” value for each parameter to be read from an option file:  
  30. *  
  31. For host, specify a value of NULL or the empty string ("").  
  32. *  
  33. For user, specify a value of NULL or the empty string.  
  34. *  
  35. For passwd, specify a value of NULL. (For the password, a value of the empty string in  
  36. the MySQL(和PHP搭配之***組合)_real_connect() call cannot be overridden in an option file, because the empty   
  37. string indicates explicitly that the MySQL(和PHP搭配之***組合) account must have an empty password.)  
  38. *  
  39. For db, specify a value of NULL or the empty string.  
  40. *  
  41. For port, specify a value of 0.  
  42. *  
  43. For unix_socket, specify a value of NULL.   
  44. If no value is found in an option file for a parameter, its default value is used as   
  45. indicated in the descriptions given earlier in this section.  
  46. Return Values  
  47. MySQL(和PHP搭配之***組合)* connection handle if the connection was successful, NULL if the connection   
  48. was unsuccessful. For a successful connection, the return value is the same as the value   
  49. of the first parameter.  

返回值:當連接成功時,返回MySQL數據庫連接句柄,失敗,返回NULL。當成功時,返回值與***個參數值是// 相同的。

 

  1. Errors  
  2. *  
  3. CR_CONN_HOST_ERROR  
  4. Failed to connect to the MySQL(和PHP搭配之***組合) server.  
  5. *  
  6. CR_CONNECTION_ERROR  
  7. Failed to connect to the local MySQL(和PHP搭配之***組合) server.  
  8. *  
  9. CR_IPSOCK_ERROR  
  10. Failed to create an IP socket.  
  11. *  
  12. CR_OUT_OF_MEMORY  
  13. Out of memory.  
  14. *  
  15. CR_SOCKET_CREATE_ERROR  
  16. Failed to create a Unix socket.  
  17. *  
  18. CR_UNKNOWN_HOST  
  19. Failed to find the IP address for the hostname.  
  20. *  
  21. CR_VERSION_ERROR  
  22. A protocol mismatch resulted from attempting to connect to a server with a client   
  23. library that uses a different protocol version. This can happen if you use a very old   
  24. client library to connect to a new server that wasn't started with the --old-protocol   
  25. option.  
  26. *  
  27. CR_NAMEDPIPEOPEN_ERROR  
  28. Failed to create a named pipe on Windows.  
  29. *  
  30. CR_NAMEDPIPEWAIT_ERROR  
  31. Failed to wait for a named pipe on Windows.  
  32. *  
  33. CR_NAMEDPIPESETSTATE_ERROR  
  34. Failed to get a pipe handler on Windows.  
  35. *  
  36. CR_SERVER_LOST  
  37. If connect_timeout > 0 and it took longer than connect_timeout seconds to connect to   
  38. the server or if the server died while executing the init-command.   

 

因此MySQL(和PHP搭配之***組合)_real_connect()函數調用為:

MySQL(和PHP搭配之***組合)_real_connect(MySQL數據庫,"localhost","root",NULL,"test",0,NULL,0);

判斷是否出錯,出錯調用MySQL(和PHP搭配之***組合)_error()函數顯示出錯信息,或使用MySQL(和PHP搭配之***組合)_errno()函數獲取出錯代號。

【編輯推薦】

  1. MySQL EMS的亂碼問題的殲滅
  2. MySQL表索引遭到破壞的處理方法
  3. 開源攜手MySQL數據庫的發展前景
  4. MySQL root 密碼忘記的破解
  5. Linux上實現MySQL 5的手動安裝

 

責任編輯:佚名 來源: 互聯網
相關推薦

2010-05-13 14:07:39

MySQL數據庫

2010-05-28 14:51:47

MySQL數據庫

2010-05-25 14:05:52

MySQL數據庫

2021-12-13 22:59:23

MySQL數據庫SQL

2010-06-04 15:32:18

MySQL數據庫

2010-05-28 18:44:45

2011-03-28 13:25:27

MySQL數據庫哈希加密

2017-10-25 15:27:52

MySQL數據庫超時設置

2011-03-08 08:49:55

MySQL優化單機

2019-11-07 15:39:36

數據庫MySQL文章

2010-06-04 14:25:23

MySQL數據庫權限

2011-04-07 09:06:27

MySQL數據庫密碼

2010-06-01 11:28:43

MySQL數據庫

2023-05-29 15:23:37

MySQL數據庫函數

2018-07-30 15:00:05

數據庫MySQLJOIN

2010-06-04 11:28:05

MySQL數據庫

2010-05-20 14:25:25

2011-02-22 14:26:04

ProFTPD

2011-02-22 14:26:04

ProFTPD

2010-05-27 18:44:14

MySQL遠程連接
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品一区二 | 亚洲高清三级 | 久精品视频| 久久免费精品 | 日韩亚洲一区二区 | 激情五月婷婷综合 | 色男人的天堂 | 成人在线免费看 | 亚洲一区二区在线视频 | 亚洲国产高清高潮精品美女 | 亚洲精品免费观看 | 欧美一级www片免费观看 | 午夜视频在线免费观看 | 欧美黑人狂野猛交老妇 | 国产精品毛片一区二区在线看 | 牛牛热在线视频 | 玖玖综合网 | 国产亚洲精品久久久久久豆腐 | 国产精品精品 | 日韩成人免费视频 | 伊人精品久久久久77777 | 日韩欧美国产成人一区二区 | 97精品超碰一区二区三区 | 日韩av美女电影 | 精品一区二区久久久久久久网精 | 毛片久久久| 一区二区三区高清 | 国产做a爱片久久毛片 | 超碰在线亚洲 | 日韩靠逼 | 亚洲精品福利视频 | 成人在线h | 99久久久久久99国产精品免 | 午夜精品一区二区三区在线观看 | 欧区一欧区二欧区三免费 | 国产精品一区二区三区四区 | av手机在线看 | 91麻豆蜜桃一区二区三区 | 亚洲国产精久久久久久久 | 99资源 | 国产福利视频导航 |