You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user ‘root’@’localhost’ identified by ‘123456’;
You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user ‘root’@’localhost’ identified by ‘123456’;
iptables中加
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10221:10231 -j ACCEPT
/etc/vsftpd/vsftpd.conf
pasv_enable=YES
pasv_min_port=10221 #随机最小端口,原来是4000
pasv_max_port=10231 #随机最大端口,原来是5000.
PASV(被动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。
当需要传送数据时,服务器在命令链路上用 PASV命令告诉客户端:“我打开了一个1024+的随机端口,你过来连接我”。于是客户端向服务器的1024+端口发送连接请求,建立一条数据链路来传送数据。
Centos系统的setfacl给用户设置权限时报错提示Operation not supported
问题:/mnt/bak为硬盘的一个分区,在fstab做了defaults挂载,当设定acl
命令为:setfacl -m u:luo:rwx /mnt/bak的时候提示
setfacl: /mnt/bak: Operation not supported 错误
解决方法:重新修改/etc/fstab文件,加入acl选项
/dev/vg/bak /mnt/bak ext3 defaults,acl 0 0
然后:mount -o remount /mnt/bak 重新挂载,再执行上面的命令,成功!
create table table1 (id bigint unsigned auto_increment primary key,col int);
insert into table1 values (18446744073709551613,1);
insert into table1 values (null,1);
insert into table1 values (null,1);
[ERROR in query 4] Failed to read auto-increment value from storage engine
select 18446744073709551614/(60*60*24*365*1000000);
1年31536000秒,每秒产生一百万条,结果为584942年(58万年)。
/** * 计算身份证校验码,根据国家标准GB 11643-1999 * @param unknown $idcard_base * @return boolean|string */function idcard_verify_number($idcard_base) { if (strlen($idcard_base) != 17) { return false; } //加权因子 $factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); //校验码对应值 $verify_number_list = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); $checksum = 0; for ($i = 0; $i < strlen($idcard_base); $i++) { $checksum += substr($idcard_base, $i, 1) * $factor[$i]; } $mod = $checksum % 11; $verify_number = $verify_number_list[$mod]; return $verify_number;}/** * 将15位身份证升级到18位 */function idcard_15to18($idcard) { if (strlen($idcard) != 15) { return false; } else { // 如果身份证顺序码是996 997 998 999,这些是为百岁以上老人的特殊编码 if (array_search(substr($idcard, 12, 3), array('996', '997', '998', '999')) !== false) { $idcard = substr($idcard, 0, 6) . '18' . substr($idcard, 6, 9); } else { $idcard = substr($idcard, 0, 6) . '19' . substr($idcard, 6, 9); } } $idcard = $idcard . idcard_verify_number($idcard); return $idcard;}/** * 18位身份证校验码有效性检查 * @param unknown $idcard * @return boolean */function idcard_checksum18($idcard) { if (strlen($idcard) != 18) { return false; } $idcard_base = substr($idcard, 0, 17); if (idcard_verify_number($idcard_base) != strtoupper(substr($idcard, 17, 1))) { return false; } else { return true; }}当我们在做微信微博sdk分享的时候调试非常麻烦,因为要使用对应的签名版本才能调用sdk成功。
当我们使用AndroidStudio的Gradle之后会很简单的解决这个问题。
1.我们把签名文件放到工程根目录下(这样做是为了保持路径的统一)
2.在Gradle中引入如下代码: app/build.gradle
android {
compileSdkVersion 22
buildToolsVersion “22.0.1”
//配置keystore签名
signingConfigs {
release {
storeFile file(“xxxxxx.jks”)
storePassword “xxxxxx”
keyAlias “my team”
keyPassword “xxxxxx”
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
}
}
}
这样编译出来的debug版本直接用的是正式签名
安装 pcre
sudo apt-get install build-essential
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
./configure
make
sudo make install
sudo apt-get install libtool
sudo apt-get install libssl-dev
sudo /usr/local/nginx/sbin/nginx
apt-get install python-gevent python-pip
pip install shadowsocks
安装shadowsocks了。
接下来配置也比较简单,找到shadowsocks文件夹: sudo find / -name shadows*
新建一个 config.json,或者其他名字的都行,位置可以放在/etc/shadowsocks/下(默认没有这个文件,你要自己创建一个),或者home或者其他地方。
内容是
{
“server”:”my_server_ip”,
“server_port”:8388,
“local_port”:1080,
“password”:”barfoo!”,
“timeout”:600,
“method”:”aes-256-cfb”
}
具体含义wiki上给的也很清楚
server 服务器 IP (IPv4/IPv6),注意这也将是服务端监听的 IP 地址
server_port 服务器端口
local_port 本地端端口
password 用来加密的密码
timeout 超时时间(秒)
method 加密方法,可选择 “bf-cfb”, “aes-256-cfb”, “des-cfb”, “rc4”, 等等。默认是一种不安全的加密,推荐用 “aes-256-cfb”
apt-get install python-m2crypto
然后就可以启动服务了。
ssserver -c /etc/shadowsocks/config.json
当然了,你不可能一直开着ssh,所以还是
nohup ssserver -c /etc/shadowsocks/config.json &
然后可以关了SSH。
或者更直接的开机自启动,添加到rc.local
Top命令监控某个进程的资源占有情况
下面是各种内存:
VIRT:virtual memory usage
1、进程“需要的”虚拟内存大小,包括进程使用的库、代码、数据等
2、假如进程申请100m的内存,但实际只使用了10m,那么它会增长100m,而不是实际的使用量
RES:resident memory usage 常驻内存
1、进程当前使用的内存大小,但不包括swap out
2、包含其他进程的共享
3、如果申请100m的内存,实际使用10m,它只增长10m,与VIRT相反
4、关于库占用内存的情况,它只统计加载的库文件所占内存大小
SHR:shared memory
1、除了自身进程的共享内存,也包括其他进程的共享内存
2、虽然进程只使用了几个共享库的函数,但它包含了整个共享库的大小
3、计算某个进程所占的物理内存大小公式:RES – SHR
4、swap out后,它将会降下来
DATA
1、数据占用的内存。如果top没有显示,按f键可以显示出来。
2、真正的该程序要求的数据空间,是真正在运行中要使用的。
CORS 跨域资源共享(Cross-Origin Resource Sharing)
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// 此时即支持CORS的情况
// 检查XMLHttpRequest对象是否有“withCredentials”属性
// “withCredentials”仅存在于XMLHTTPRequest2对象里
xhr.open(method, url, true);
} else if (typeof!= "undefined") {
// 否则检查是否支持XDomainRequest,IE8和IE9支持
// XDomainRequest仅存在于IE中,是IE用于支持CORS请求的方式
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
// 否则,浏览器不支持CORS
xhr = null;
}
return xhr;
}
var xhr = createCORSRequest('GET', url);
if (!xhr) {
throw new Error('CORS not supported');
}
服务器端
<?php
header("Access-Control-Allow-Origin:*");