代码拉取完成,页面将自动刷新
【环境信息】
系统:21.03
镜像:base和everything
【问题复现步骤】
【预期结果】
【实际结果】
问题分析 :
radsqlrelay命令的-P是指定端口号,此处的端口号似乎未生效,radsqlrelay执行完,第一条打印信息如下:
Connecting to DBI:mysql:database=radius;host=localhost;port=33.
从信息中,可以看到port被使用了……
radsqlrelay是perl脚本,最终会调用perl-DBD-MySQL包提供的DBD::connect连接数据库
下面是DBI的使用demo
=head1 NAME
DBD::mysql - MySQL driver for the Perl5 Database Interface (DBI)
=head1 SYNOPSIS
use DBI;
my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
my $dbh = DBI->connect($dsn, $user, $password);
my $sth = $dbh->prepare(
'SELECT id, first_name, last_name FROM authors WHERE last_name = ?')
or die "prepare statement failed: $dbh->errstr()";
$sth->execute('Eggers') or die "execution failed: $dbh->errstr()";
print $sth->rows . " rows found.\n";
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, fn = $ref->{'first_name'}\n";
}
$sth->finish;
=head1 EXAMPLE
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
"joe", "joe's password",
{'RaiseError' => 1});
# Drop table 'foo'. This may fail, if 'foo' doesn't exist
# Thus we put an eval around it.
eval { $dbh->do("DROP TABLE foo") };
print "Dropping foo failed: $@\n" if $@;
从demo中可以看到,当host为localhost时,似乎不需要指定port
关于port,脚本中给出了说明:
=item port
The hostname, if not specified or specified as '' or 'localhost', will
default to a MySQL server running on the local machine using the default for
the UNIX socket. To connect to a MySQL server on the local machine via TCP,
you must specify the loopback IP address (127.0.0.1) as the host.
Should the MySQL server be running on a non-standard port number,
you may explicitly state the port number to connect to in the C<hostname>
argument, by concatenating the I<hostname> and I<port number> together
separated by a colon ( C<:> ) character or by using the C<port> argument.
To connect to a MySQL server on localhost using TCP/IP, you must specify the
hostname as 127.0.0.1 (with the optional port).
When connecting to a MySQL Server with IPv6, a bracketed IPv6 address should be used.
Example DSN:
my $dsn = "DBI:mysql:;host=[1a12:2800:6f2:85::f20:8cf];port=3306";
1)如果host不指定,或指定为""或localhost,那么port将不作用,即不使用port
2)如果host指定为ip地址,那么port指定的端口才起作用
验证如下 :
[root@localhost maminjie]# radsqlrelay -1 -d mysql -b radius -h 127.0.0.1 -u root -p 123456 -P 33 -x test.sql
Connecting to DBI:mysql:database=radius;host=127.0.0.1;port=33.Sleeping for 1 secs.
.Sleeping for 1 secs.
.Sleeping for 1 secs.
.Sleeping for 1 secs.
^C[root@localhost maminjie]# radsqlrelay -1 -d mysql -b radius -h localhost -u root -p 123456 -P 33 -x test.sql
Connecting to DBI:mysql:database=radius;host=localhost;port=33.
Waiting for test.sql
Renamed test.sql to test.sql.work
Opening test.sql.work
Getting file lock
Reading: I.>Table 'radius.wu' doesn't exist
Sleeping for 1 secs.
No more lines to read, doing any final inserts: I
Processed 1 lines
Removing and closing test.sql.work
Disconnecting from database
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
结论 :
1)如果host不指定,或指定为""或localhost,那么port将不作用,即不使用port
2)如果host指定为ip地址,那么port指定的端口才起作用
登录 后才可以发表评论