我有大约50个数据库都设置在不同的主机名,要求我通过SSH隧道连接到它们.
例如:
SSH主机在 ssh.example.com
MySQL主持人在 mysql1.example.com
我已经设法使用autossh(运行Debian的Web服务器)创建隧道,但我似乎无法弄清楚如何连接到SSH隧道之外的特定MySQL主机名.
键入lsof -i -n | egrep '\<ssh\>'确认隧道正在工作(将端口3307发送到ssh.example.com端口3306)
因此,当我尝试时,我mysql -h 127.0.0.1 -P 3307拒绝Connection.不太奇怪,因为它不是MySQL服务器.
我向你们提问:
如何在mysql1.example.com创建SSH隧道后指定主机?我试过到处寻找,但似乎无法弄明白.
在页面加载时,我正在尝试使用initSelection来选择ID 60 (输入字段的指定值).我似乎无法让它正常工作.
PHP脚本工作得很好并返回正确的值,但是如何让JS正确地进行回调呢?
JavaScript的:
$(document).ready(function() {
$('#editAlbumArtistId').select2({
placeholder: 'Search names',
ajax: {
url: "/jQueryScripts/jQuerySelectListArtists.php",
dataType: 'json',
quietMillis: 100,
data: function (term, page) {
return {
term: term, //search term
page_limit: 10 // page size
};
},
results: function (data, page) {
return {results: data.results};
}
},
initSelection: function(element, callback) {
var id = $(element).val();
if(id !== "") {
$.ajax("/jQueryScripts/jQuerySelectListArtists.php", {
data: {id: id},
dataType: "json"
}).done(function(data) {
callback(data);
});
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<p>
<input type='hidden' value="60" …Run Code Online (Sandbox Code Playgroud) 我需要在其中存储带有通配符的IP地址,例如10.0.%.1.然后,我希望从我的查询中找到任何IP地址在允许范围(10.0.0-255.1)的人.
你能帮我吗?我已经尝试存储10.0.%.1但是找不到LIKE查询(我甚至不知道这是不是这样做 - 可能不是).
提前致谢.
我有最奇怪的PHP PDO问题,我希望你们能为我解决这个问题.
如果我设置$checkLimit为50000,查询工作正常.但是,如果我将它设置为高于50k的任何值,它不会返回任何结果 - 并且它也不会抛出任何错误消息(我已经使用了它们$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING).
$sql = "
SELECT d_domain_name AS domainName, d_domain_id AS domainID
FROM domains
ORDER BY d_domain_name_length ASC, d_domain_name ASC
LIMIT :checkLimit
";
$stmt = $db->prepare($sql);
$stmt->bindValue(':checkLimit', intval($checkLimit), PDO::PARAM_INT);
$stmt->execute();
$results = $stmt->fetchAll();
foreach ($results as $result) {
// 50k moments of magic
}
Run Code Online (Sandbox Code Playgroud)
如果我在PHP之外运行查询,它可以使用任何限制(甚至500k,大约需要3分钟).
我已经尝试过更改$results = $stmt->fetchAll()以while ($result = $stmt->fetch()) {}尝试节省内存,但不幸的是,这没有做任何事情.
谁能告诉我这里我做错了什么?我错过了什么?为什么我不能超过50k?
所以我一直在寻找一段时间,我开始发疯了.我显然不是RegEx专家,但我希望你能快点帮我.
我正在尝试编写一个正则表达式行,它将取代两个破折号,不多也不少.应该忽略一个破折号,并且应该忽略三个破折号.
我想出了这个,但它循环:
[--]{2}
Run Code Online (Sandbox Code Playgroud)
这没有给我什么:
^[--]{2}$
Run Code Online (Sandbox Code Playgroud)
请帮帮我!谢谢!
我的查询在下面(它搜索父母和孩子4个级别上下).这样,我得到一个"num"值中找到的行数:大约~22k行.
SELECT COUNT(fts_trip_id) AS num
FROM feed_trips_se
JOIN departures ON d_departure_id=fts_trip_departure_id
JOIN destinations ON destinations.d_destination_id=d_departure_id
LEFT JOIN destinations AS destChild1 ON destChild1.d_destination_parent_id=destinations.d_destination_id
LEFT JOIN destinations AS destChild2 ON destChild2.d_destination_parent_id=destChild1.d_destination_id
LEFT JOIN destinations AS destChild3 ON destChild3.d_destination_parent_id=destChild2.d_destination_id
LEFT JOIN destinations AS destChild4 ON destChild4.d_destination_parent_id=destChild3.d_destination_id
LEFT JOIN destinations AS destParent1 ON destParent1.d_destination_id=destinations.d_destination_parent_id
LEFT JOIN destinations AS destParent2 ON destParent2.d_destination_id=destParent1.d_destination_parent_id
LEFT JOIN destinations AS destParent3 ON destParent3.d_destination_id=destParent2.d_destination_parent_id
LEFT JOIN destinations AS destParent4 ON destParent4.d_destination_id=destParent3.d_destination_parent_id
WHERE fts_trip_date>=NOW()
ORDER BY fts_trip_date ASC, fts_trip_price ASC
Run Code Online (Sandbox Code Playgroud)
但是,由于我使用了大量LEFT …