4月 09

忘记 mysql 密码

1. 先结束mysql 进程

# killall mysqld

2. 用mysql 安全模式运行并跳过权限难

# mysqld_safe –skip-grant-tables

3. 用root 登录 ,此时不需要密码

# mysql -u root

4. 现在开始修改密码了

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set Password = PASSWORD(‘your new password’) where User = ‘root’ ;

Query OK, 2 rows affected (0.02 sec)

Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;

mysql> quit

Bye

4月 09

获取系统变量

脚本中获取系统变量:

  $0 这个程序的执行名字

  $n  这个程序的第n个参数值,n=1…9

  $*  这个程序的所有参数

  $# 这个程序的参数个数

  $$ 这个程序的PID

  $! 执行上一个背景指令的PID

  $? 上一个指令的返回值