系统运维

占位

删除过期账号实例

1、导出一个注册用户表的用户名数据

2、导出最近一年登陆的用户名数据

比较两个文件的差异

grep -wvFf file1.txt file1.txt

//存在于file2文件中,但不存在于file1文件的行

替换每行的后缀

sed -ie 's/@xxx$/@xxx.com/' xxx.txt

查找文件某行数据

sed -n '3457,1p' xxx.txt

InputStream、byte[] 互转

InputStream转byte[]

private byte[] getBytesFromInputStream(InputStream is) throws IOException {
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
int ch;
while ((ch = is.read()) != -1) {
bytestream.write(ch);
}
byte imgdata[] = bytestream.toByteArray();
bytestream.close();
return imgdata;
}

byte[]转InputStream

byte[] data;
InputStream is = new ByteArrayInputStream(data);

http://mingkg21.javaeye.com/blog/431067

Ubuntu安装MySQL

好久没写日志了,前段时间,域名没有备案,封掉了。

Ubuntu安装MySQL很方便,直接运行

sudo apt-get install mysql-server

就可以了。

但如果要MySQL能够外部访问的话,要做下修改。
登录MySQL

mysql -u root -p

授予需要外部访问的IP或者用户的权限

GRANT ALL PRIVILEGES ON *.* TO shishuo@'%' IDENTIFIED BY "shishuopassword"; 

其中 *.* 表示 数据库.表,你可以写为 shishuo.*
如:

GRANT ALL PRIVILEGES ON shishuodatabase.* TO shishuo@'%' IDENTIFIED BY "shishuopassword"; 

这条语句的意思就是,shishuo这个用户可以在任何IP下,用 shishuopassword 密码,访问shishuodatabase数据库,并具有对shishuodatabase的所有权限。

然后

vi /etc/mysql/my.cnf

修改
bind-address = 127.0.0.1

#bind-address = 127.0.0.1

重启

/etc/init.d/mysql restart

这样外部也能访问了。