现在的位置: 首页 > 综合 > 正文

2006-05-25 (1)mysql

2014年01月05日 ⁄ 综合 ⁄ 共 1061字 ⁄ 字号 评论关闭

忘记mysql 的root 密码:
先确认已经杀掉mysqld 进程了,然后执行这个
/usr/bin/safe_mysqld --skip-grant-tables &
再这样登录
mysql -h 192.168.1.2 -u root
上边的192.168.1.2 是cloud 的mysqld 运行机器,你换成自己的,这样登录上
去,就可以修改密码了。
修改密码
1.mysql -h hostname –u root 命令登录到mysqld server 用grant 命令改变口令:
Grant all on *.* to root indentified by "111111"      ||||||||  grant all on *.* to root@192.168.1.1 indentified by ''; 
2. mysqladmin -u 用户名-p 旧密码password 新密码

3.显示限制行数

select * from databasename.tablename limit begin,countfoyouwant;

4.alter table tablename change[drop,add] columname columname atrributes;

5.update tablename set attr2=if(attr1=valu1,valu2,valu3)  ……;

6.delete from tablename;

7.insert into tablename values(……); 

8.select * from (select * from table1 where ……) tm where……//嵌套查询

9. select  case when b<0 then ''

                        when b between 5 and 38 then ''

                       end   from tablename       //case语句的使用注case后不能加参数

 10.select * from tablea where IF((select COUNT(*) from b)>100,a,b)//条件语句中可以加入if语句进行嵌套

11.strname<>''                 <===|||===>            strname is not NULL

12.strname like '%%'             不能查出空值          strname is NULL

13. select count(*) from b where …… group by attr1 having count(*) <10;

【上篇】
【下篇】

抱歉!评论已关闭.