寻觅生命中的那一片浅草......

每月存档 十一月, 2009

mysql_drop_user错误

mysql> drop user ‘test_s99’@’%’;
ERROR 1268 (HY000): Can’t drop one or more of the requested users

revoke all on test_s99.* from ‘test_s99’@’localhost’;
drop user ‘test_s99’@’localhost’;

The DROP USER statement removes one or more MySQL accounts. To use it, you must have the DELETE privilege for the mysql database. Each account is named using the same format as for the GRANT  statement; for example, ‘jeffrey’@’localhost’. If you specify only the user name part of the account name, a host name part of ‘%’ is used. For additional information about specifying account names, see Section 12.5.1.2, “GRANT Syntax”.

DROP USER was added in MySQL 4.1.1. In MySQL 4.1, it serves only to remove account rows from the user table for accounts that have no privileges. To remove a MySQL account completely (including all of its privileges), you should use the following procedure, performing the steps in the order shown:

1.

Use SHOW GRANTS to determine what privileges the account has. See Section 12.5.5.12, “SHOW GRANTS Syntax”.
2.

Use REVOKE to revoke the privileges displayed by SHOW GRANTS. This removes rows for the account from all the grant tables except the user table, and revokes any global privileges listed in the user table. See Section 12.5.1.2, “GRANT Syntax”.
3.

Delete the account by using DROP USER to remove the user table row.

In MySQL 5.0.2 and up, DROP USER removes the account row in the user table and also revokes the privileges held by the account. It is not necessary to use DROP USER in conjunction with REVOKE.
Important

DROP USER does not automatically close any open user sessions. Rather, in the event that a user with an open session is dropped, the statement does not take effect until that user’s session is closed. Once the session is closed, the user is dropped, and that user’s next attempt to log in will fail. This is by design.

Before MySQL 4.1.1, DROP USER is not available. You should first revoke the account privileges using SHOW GRANTS and REVOKE as just described. Then delete the user table row and flush the grant tables as shown here:

http://dev.mysql.com/doc/refman/4.1/en/drop-user.html

date转换时间和时间戳

时间戳 to 时间
date -d ‘1970-01-01 UTC 946684800 seconds’ +”%Y-%m-%d %T %z”

时间 to 时间戳
date -d ‘2006-02-14 00:00:00’ +%s

info date
看example小节的最后有详细说明

chkconfig在ubuntu里用什么命令替代

# update-rc.d sshd defaults          # Activate sshd with the default runlevels
# update-rc.d sshd start 20 2 3 4 5 . stop 20 0 1 6 .  # With explicit arguments
# update-rc.d -f sshd remove         # Disable sshd for all runlevels
# shutdown -h now (or # poweroff)    # Shutdown and halt the system

top libncurses.so.4

在linux操作系统下,执行 top 命令出现了 “error while loading shared libraries: libncurses.so.4…”报错信息,原因是系统找不到libncurses.so.4文件。解决方法如下:

# cd /usr/lib        //进入到/usr/lib目录下

# ls -la libncurses.so*     //查询文件名包含libncurses.so字符串的文件

libncurses.so  libncurses.so.5  libncurses.so.5.4     //系统返回的查询结果
可见虽然没有libncurses.so.4文件,但有libncurses.so.5.4文件,只要建一个ln就好了,命令如下:

# ln -s  /usr/lib/libncurses.so.5.4  /usr/lib/libncurses.so.4

转载自:http://blog.csdn.net/gavin8197/archive/2008/12/19/3556326.aspx

史上最强bash函数库

多为系统操作相关,如

取内网地址: get_localip()
取内网网口: get_local_iface()
取网关的IP:  get_gateway_ip()
添加一个cron作业: add_cron()
删除一个cron作业: del_cron()
取内存大小: get_mem_size()
取硬盘大小: get_hdd_size()
查找非系统默认帐号:find_non_sys_user()
………

使用方法:
将func-common.sh和主脚本放在同一个目录下
在主脚本中source函数库后直调用, 函数参数见注释说明
复制内容到剪贴板
代码:

export WORKDIR=$( cd ` dirname $0 ` && pwd )

if [[ ! -r “$WORKDIR/func-common.sh” ]]; then
echo “[$WORKDIR/func-common.sh] NOT FOUND”
exit 1
fi

. “$WORKDIR/func-common.sh” || exit 1
代码存于google svn中, 会不定期更新
http://huan.googlecode.com/svn/bash/func-common.sh

转载自:http://bbs.linuxeden.com/thread-192227-1-1.html

2009年十一月
« 10月   12月 »
 1
2345678
9101112131415
16171819202122
23242526272829
30