修改MySQL数据库登陆密码的方法
MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。
(1)命令
/usr/bin/mysqladmin -u root –p ‘old-password’ password 'new-password'
格式:mysqladmin -u用户名 -p旧密码 password 新密码
(2)例子
例1:给root加个密码123456。
键入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
(3)测试是否修改成功
1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO) 显示错误,说明密码已经修改。
2)用修改后的密码登录
[root@test1 local]# mysql -u root -p
Enter password: (输入修改后的密码123456)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
成功!
这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。
相关文档:
http://javeye.javaeye.com/blog/558093
我们知道,group by可以将sql查询结果按照group by后面列进行分类显示。比如:
Sql代码
select
columnA,columnB
from
table
group
by
columnA,columnB
select columnA,columnB from table group by columnA,colum ......
MSSQL 如何实现 MySQL 的 limit 查询方式
不知为何,MSSQL 中没有 limit 这个极为重要的查询方式,熟悉 MySQL 的朋友都知道,MySQL 的 limit 对于实现分页和一些限制结果集的应用中非常方便。没有不要紧,我们可以用其他方法达到同样的目的,自己动手,丰衣足食!
语法:
Code:
SELECT * from
(
......
首先需要查看一下创建函数的功能是否开启:
X:\proper\mysql\bin>mysql -h localhost -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.0.22-community-nt-log
Type 'help;' or '\h' for help. Type ' ......
(1)格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"
(2)例1、增加一个用户user_1密码为123,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令:
mysql> grant select,insert,update,delete on *.* to use ......