This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Connecting to the Server”.
1. Which library file contains various portability macros and definitions?
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
View Answer
Explanation: The ‘my_sys.h’ header file contains a variety of portability macros and definitions required for structures and functions. These structures and functions are used by the client library.
2. Which header should be included first?
a) my_global.h
b) my_sys.h
c) mysql.h
d) my_local.h
View Answer
Explanation: The file ‘my_global.h’ takes care of including several other header files that are likely to be generally useful, like ‘stdio.h’. It also includes Windows compatibility information.
3. mysql_init() returns a _____________
a) integer
b) float
c) structure
d) pointer to a structure
View Answer
Explanation: When NULL is passed to mysql_init() it automatically allocates a MYSQL structure, initializes it, and returns a pointer to it. The MYSQL data type is a structure containing information about a connection.
4. When linking to a static MySQL C client library, the client library and the client application must use the same compiler option.
a) True
b) False
View Answer
Explanation: Generally, when linking to a static MySQL C client library, the client library and the client application must use the same compiler option when it is required to link the C runtime.
5. Which of these can be used in place of MYSQL_SERVER_VERSION?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
View Answer
Explanation: The macros ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID’ and the two sets of macros can be used in place of each other.
6. Which of the following can be used interchangeably with MYSQL_VERSION_ID?
a) LIBMYSQL_VERSION
b) LIBMYSQL_VERSION_ID
c) MYSQL_VERSION_ID
d) MYSQL_ID
View Answer
Explanation: The ‘LIBMYSQL_VERSION’ and ‘LIBMYSQL_VERSION_ID’ macros have the same values as ‘MYSQL_SERVER_VERSION’ and ‘MYSQL_VERSION_ID’ and the two sets of macros can be used interchangeably.
7. Which option is supplied to ensure TCP/IP connection to local server?
a) –localhost
b) –host
c) –hostlocal
d) –connectlocal
View Answer
Explanation: In order to ensure that the client makes a TCP/IP connection to the local server, the ‘–host’ or ‘-h’ option is used to specify a host name value of 127.0.0.1 or the IP address of the local server.
8. Connections to remote servers always use TCP/IP.
a) True
b) False
View Answer
Explanation: The connections to remote servers always use TCP/IP. To connect to the server running on remote.example.com using the default port number (3306) this command is used: mysql –host=remote.example.com.
9. The –protocol value ‘TCP’ runs on which operating systems?
a) all
b) unix only
c) windows only
d) none
View Answer
Explanation: The connection protocol used by the option ‘–protocol = TCP’ indicates TCP/IP connection to the local or the remote server. Each –protocol value has the set of permissible OS.
10. The ‘SOCKET’ protocol is permitted on which operating systems?
a) all
b) unix only
c) windows only
d) none
View Answer
Explanation: The connection protocol used by the option ‘–protocol = SOCKET’ indicates the unix socket file connection to the local server. Each –protocol value has the set of permissible OS.
Sanfoundry Global Education & Learning Series – MySQL Database.
To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Information Technology Books
- Apply for Programming Internship
- Check MySQL Books
- Practice Programming MCQs