MySQL database security solution (3) tip: With the popularization of the network, more and more network-based applications are available. Network databases are one of them. One or several servers can provide services to many customers. this method brings a lot of convenience to people, but it also gives criminals a chance to take advantage of it. Because the data is transmitted over the network, it can be intercepted during the transmission process, or it can be accessed through a very convenient way.
OpenSSL has been added to the Windows version of MySQL. The preceding command is to check whether SSL is enabled for your MySQL instance.
Show variables like 'have _ openssl ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Have_openssl | NO |
+ --------------- + ------- +
1 row in set (0.00 sec)
If NO is returned, you need to compile OpenSSL into your MySQL
Sometimes you may need to encrypt the user name and password for transmission. In this case, you can use the following GRANT command:
Grant all privileges on ssl_only_db. * to 'ABC' @ '%' identified by "password! "Require ssl;
You can also use the REQUIRE x509 option for SSL transmission:
Grant all privileges on ssl_only_db. * to 'ABC' @ '%' identified by "password! "REQUIRE x509;
You can also use require subject to specify a specific client certificate to access the database.
Grant all privileges on ssl_only_db. * to 'ABC' @ '%'
Identified by "password! "
Require subject "/C = US/ST = New York/L = Albany/O = Widgets Inc./CN = client-ray.
Example.com/emailAddress=raymond@example.com ";
Maybe you don't care about what customer licenses you are using, but only about your certificates. Then you can use require issuer to implement:
Grant all privileges on ssl_only_db. * to 'ABC' @ '%' identified by "password! "
Require issuer "/C = US/ST = New + 20 York/L = Albany/O = Widgets Inc./CN = cacert. example.
Com/emailAddress = admin@example.com ";
SSL can also be encrypted directly with a password. You can use require cipher to set the password.
Grant all privileges on ssl_only_db. * to 'ABC' @ '%' identified by "password! "
Require cipher "EDH-RSA-DES-CBC3-SHA ";
The GRANT command is used to set user permissions. The information is stored in the authorization table, which is the heart of the security system. The permissions of each user and client are saved in these tables. Correct operations on these tables will play a positive role in database security, and it will be very dangerous if you accidentally use these tables.