One of the DNS parsing probes for MySQL: DNS parsing does work

Source: Internet
Author: User
Tags mysql command line

Machine A--192.168.103.94--Server

Machine B - -and 192.168.4.2--Client

Machine A =

Install Mysql-server, start; Use the root user login to see if DNS resolution is turned on, and execute the following command:

Mysql> Show variables like ' skip_name_resolve% '; +-------------------+-------+| variable_name | Value |+-------------------+-------+| Skip_name_resolve | OFF |+-------------------+-------+1 row in Set (0.00 sec)

Indicates that DNS resolution is enabled

Add in/etc/hosts:

192.168.4.2 Mysql_client_host

Add user testdns,host to 192.168.4.2 in MySQL

mysql> grant all privileges on  *.* to [email protected] ' 192.168.4.2 '  identified by  ';mysql>  ' Select user,host,password from user where user= ' Testdns ';  +---------+----------- --+-------------------------------------------+| user    | host         | password                                    |+---------+-------------+------------------------------------------ -+| testdns | 192.168.4.2 | *b66feb4cf5216d971c066eb920ec03b27a5a3f40 |+-------- -+-------------+-------------------------------------------+mysql> flush privileges; 

Machine B =

Prepare a set of JDBC test programs:

Db.driver=com.mysql.jdbc.driver

Db.url=jdbc:mysql://192.168.103.94:3306/test

Db.username=testdns

db.password=000

Execute the "SELECT 1" query statement: the query succeeded!

Machine a=> View the list of connection processes:

mysql> show processlist;+----+---------+------------------------+-------+---------+------+------- +------------------+| id | user    | host                    | db     | Command | Time | State | Info              |+----+---------+------------------------+-------+------ ---+------+-------+------------------+|  3 | root    | localhost               | mysql |  Query   |    0 | null  | show processlist  | |   4 | testdns | mysql_client_host:4192 | test  | sleep    |    2 |       | null              |+----+---------+------------------------+-------+------ ---+------+-------+------------------+

The host name shown here is Mysql_client_host, which indicates that DNS resolution is working

Continue to guess when the host of Testdns is set to mysql_client_host it is also possible to verify the following:

Test execution of the "SELECT 1" query statement on machine B: The query was successful!

A machine will comment out the 192.168.4.2 mysql_client_host in/etc/hosts, and the MySQL command line executes flush hosts, because MySQL caches DNS parsing records;

The B machine is tested again,

Java.sql.SQLException:null, message from server: "Host ' 192.168.4.2 ' isn't allowed to connect to this MySQL server"

At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:996)

At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:935)

At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:924)

Section: The above test proves that the DNS parsing of MySQL is actually working


One of the DNS parsing probes for MySQL: DNS parsing does work

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.