mysql banner

MySQL Multiple Choice Questions (MCQs) and Answers

Master MySQL with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of MySQL concepts. Begin your placement preparation journey now!

Q121

Q121 How does MySQL Cluster achieve high availability?

A

By using shared storage

B

By using disk mirroring

C

By synchronously replicating data across nodes in real-time

D

By periodically backing up data

Q122

Q122 What is the primary benefit of using Galera Cluster over standard MySQL replication?

A

Faster data replication

B

Automatic node provisioning

C

Synchronous replication and automatic conflict resolution

D

Manual switching during failures

Q123

Q123 In MySQL, what does sharding help with?

A

Data recovery

B

Data archiving

C

Data scalability

D

Data encryption

Q124

Q124 What does the following MySQL command achieve?
CHANGE MASTER TO MASTER_HOST='master2', MASTER_LOG_FILE='log-bin.000012', MASTER_LOG_POS=123;

A

Initiates a new master server

B

Changes replication settings to a new master log

C

Restarts the MySQL server

D

Updates the server configuration

Q125

Q125 How does the max_connections setting affect a MySQL server?

A

Limits the number of open transactions

B

Limits the number of database users

C

Sets the maximum number of allowable connections

D

Restricts query execution time

Q126

Q126 Identify the issue with this replication setup command:
SET GLOBAL sql_slave_skip_counter = 2; START SLAVE;

A

The slave counter should not be set globally

B

This command should be followed by a server restart

C

It skips error events in replication, which can lead to data inconsistency

D

All are correct

Q127

Q127 What is a potential risk when using the LOAD DATA INFILE statement in a replication setup?

A

It can lock the table on the master

B

It might not replicate to the slave under certain configurations

C

It increases the load on the network

D

It is not supported in clustered environments

Q128

Q128 What is the difference between asynchronous and synchronous replication in MySQL?

A

Asynchronous waits for an event; synchronous does not

B

Asynchronous is faster; synchronous is slower

C

Asynchronous does not guarantee data consistency; synchronous does

D

Asynchronous uses more resources; synchronous uses less

Q129

Q129 How does MySQL Cluster (NDB) handle data partitioning?

A

Automatically partitions data across all data nodes

B

Manually partitions data based on user settings

C

Does not support data partitioning

D

Only partitions data on request

Q130

Q130 Which type of replication is preferred for high fault tolerance in MySQL Cluster?

A

Asynchronous replication

B

Synchronous replication

C

Semi-synchronous replication

D

Delayed replication

Q131

Q131 What does the following command do in the context of MySQL replication?
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;

A

Changes the replication master to a new server

B

Updates where the slave should start reading the master's binary log

C

Stops replication

D

Resets the master's binary log

Q132

Q132 How do you configure a MySQL server to act as a slave in a replication topology?

A

Use the SLAVE START command

B

Modify the my.cnf file to include master server details

C

Use the SERVER SLAVE command

D

Execute REPLICATE START on the database

Q133

Q133 In MySQL Cluster, what role does the ndb_mgmd daemon play?

A

Manages memory allocation for the cluster

B

Acts as the primary data node

C

Provides connection pooling services

D

Manages cluster configuration and node management

Q134

Q134 Identify the flaw in this replication setup command:
SET GLOBAL gtid_slave_pos='3E11-2343-23EE-2445'; START SLAVE;

A

GTID format is incorrect

B

There's no error; the command is correct

C

GTID should be set at the session level, not globally

D

It uses an outdated command structure

Q135

Q135 What’s problematic about setting up replication with the following configuration:
binlog_format=MIXED; in a cluster that supports only row-based logging?

A

Mixed format can cause errors with some queries

B

The configuration is fine

C

Row-based logging is not supported in clusters

D

Mixed format is less secure than row-based

Q136

Q136 What is a common method to connect a Python application to a MySQL database?

A

Using the PyMySQL library

B

Using the direct TCP/IP connection

C

Using SSH tunneling

D

Using XML configurations

Q137

Q137 How does JDBC handle MySQL transactions in Java applications?

A

By using auto-commit mode by default

B

By disabling transactions

C

By manual locking mechanisms

D

By using only prepared statements

Q138

Q138 When integrating MySQL with PHP, what does the PDO extension provide that the older mysql extension does not?

A

Asynchronous query execution

B

Native JSON support

C

Support for multiple databases

D

Stored procedure debugging

Q139

Q139 In the context of connecting to MySQL from a Node.js application, what is an advantage of using the mysql2 library over mysql?

A

Improved performance and prepared statements support

B

Only supports older MySQL versions

C

Includes automatic data encryption

D

Is easier to configure

Q140

Q140 What does this PHP line of code do?
$stmt = $pdo->prepare('SELECT * FROM users WHERE email = ?');

A

Prepares a SQL statement for execution with a placeholder for email

B

Executes a query to find all users

C

Connects to the 'users' database

D

Logs a user in based on email

Q141

Q141 How do you execute a transaction in a Node.js application using the mysql library?

A

Using connection.beginTransaction();

B

Using mysql.startTransaction();

C

By automatically starting on any connection.query()

D

Using transaction.commit();

Q142

Q142 What is the purpose of using ORM (Object-Relational Mapping) tools like Sequelize with MySQL?

A

To allow SQL commands to be written in JavaScript

B

To convert MySQL queries to NoSQL

C

To map database schemas to application models

D

To encrypt database communication

Q143

Q143 What could be the issue if a Python script using SQLAlchemy cannot connect to a MySQL database?

A

Incorrect database URL format

B

Outdated Python version

C

Firewall blocking the connection

D

All are correct

Q144

Q144 Identify the issue in this JDBC URL:
jdbc:mysql://localhost:3306;databaseName=mydb;user=root;password=root;

A

Incorrect delimiter used

B

Port number is wrong

C

Password should not be included

D

User should be specified with a URL parameter

Q145

Q145 What is MySQL Workbench primarily used for?

A

Database design and modeling

B

Query optimization

C

User management

D

Database replication

Q146

Q146 How does MySQL Workbench assist in optimizing SQL queries?

A

By generating query syntax

B

By visually displaying query execution plans

C

By executing queries faster

D

By rewriting queries automatically

Q147

Q147 What feature does MySQL Workbench provide for server administration?

A

Server startup and shutdown controls

B

Automatic patching

C

Cloud service integration

D

Real-time traffic monitoring

Q148

Q148 In MySQL Workbench, how is a new schema created?

A

By executing CREATE SCHEMA mySchema; in the SQL editor

B

By selecting File > New Schema

C

By using the Schema Wizard

D

By right-clicking on the Schemas panel and selecting 'Create Schema'

Q149

Q149 What does the 'Performance Dashboard' in MySQL Workbench display?

A

Current server status and system health

B

Historical data analysis

C

User session statistics

D

Detailed error logs

Q150

Q150 What common issue might occur when connecting MySQL Workbench to a MySQL server?

A

Incorrect password or username

B

Syntax errors in queries

C

Corrupted installation files

D

Network connection timeout

ad verticalad vertical
ad