MySQL Questions and Answers – Connecting to the Server

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

Answer: b
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

Answer: a
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

Answer: d
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.
advertisement
advertisement

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

Answer: a
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

Answer: a
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: b
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

Answer: b
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.
advertisement

8. Connections to remote servers always use TCP/IP.
a) True
b) False
View Answer

Answer: a
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

Answer: a
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.
advertisement

10. The ‘SOCKET’ protocol is permitted on which operating systems?
a) all
b) unix only
c) windows only
d) none
View Answer

Answer: b
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.