WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

MySQL · Advanced · question 55 of 100

What are the differences between one-way and two-way SSL authentication in MySQL, and how do you configure them?

📕 Buy this interview preparation book: 100 MySQL questions & answers — PDF + EPUB for $5

Secure Sockets Layer (SSL) is a protocol used to encrypt the communication between the client and the server, providing secure data transmission over a network. MySQL server can be configured with either one-way SSL authentication or two-way SSL authentication to establish secure connections.

One-way SSL authentication, also known as SSL client authentication, is a type of SSL authentication that only requires the client to authenticate the server. The server presents its SSL certificate to the client, and the client verifies the certificate’s authenticity. If the certificate is trusted, the connection is established, and the communication between the client and the server is encrypted.

Two-way SSL authentication, also known as mutual SSL authentication, is a type of SSL authentication that requires both the client and the server to authenticate each other. The client presents its SSL certificate to the server, and the server verifies the certificate’s authenticity. The server also presents its SSL certificate to the client, and the client verifies the certificate’s authenticity. If both certificates are trusted, the connection is established, and the communication between the client and the server is encrypted.

To configure one-way SSL authentication in MySQL, you need to generate an SSL certificate for the server and configure MySQL to use it. Here are the steps to follow:

1. Generate an SSL certificate using OpenSSL:

$ openssl req -newkey rsa:2048 -nodes -keyout server-key.pem -out server-req.pem
$ openssl x509 -req -in server-req.pem -days 365 -signkey server-key.pem -out server-cert.pem

2. Copy the server-key.pem and server-cert.pem files to the MySQL server machine.

3. Edit the MySQL configuration file (my.cnf) and add the following lines:

[mysqld]
ssl-ca=server-cert.pem
ssl-cert=server-cert.pem
ssl-key=server-key.pem

4. Restart the MySQL server.

To configure two-way SSL authentication in MySQL, you need to generate SSL certificates for both the client and the server and configure MySQL to use them. Here are the steps to follow:

1. Generate an SSL certificate for the server using OpenSSL as described above.

2. Generate an SSL certificate for the client using OpenSSL:

$ openssl req -newkey rsa:2048 -nodes -keyout client-key.pem -out client-req.pem
$ openssl x509 -req -in client-req.pem -days 365 -signkey client-key.pem -out client-cert.pem

3. Copy the client-key.pem and client-cert.pem files to the client machine.

4. Copy the server-key.pem and server-cert.pem files to the MySQL server machine.

5. Edit the MySQL configuration file (my.cnf) and add the following lines:

[mysqld]
ssl-ca=server-cert.pem
ssl-cert=server-cert.pem
ssl-key=server-key.pem
ssl-ca=client-cert.pem
ssl-cert=client-cert.pem
ssl-key=client-key.pem

6. Restart the MySQL server.

In conclusion, SSL authentication is an essential feature of MySQL that provides secure communication between the client and the server. One-way SSL authentication requires the client to authenticate the server, while two-way SSL authentication requires both the client and the server to authenticate each other. To configure SSL authentication in MySQL, you need to generate SSL certificates for the client and the server and configure MySQL to use them.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic MySQL interview — then scores it.
📞 Practice MySQL — free 15 min
📕 Buy this interview preparation book: 100 MySQL questions & answers — PDF + EPUB for $5

All 100 MySQL questions · All topics