随笔-22  评论-8  文章-0  trackbacks-0
@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

//登录MYSQL 

@>mysql -u root -p
@>密码
//创建用户

insert into mysql.user(host,user,password) values ("localhost","hbchen",p
assword("hbchen"));
这样就创建了一个名为:hbchen 密码为:hbchen (的)用户。
然后登录一下。
mysql>exit;
@>mysql -u hbchen -p
@>输入密码
mysql>登录成功
2.为用户授权。
//登录MYSQL(有ROOT权限)。我们里我们以ROOT身份登录.
@>mysql -u root -p
@>密码
//首先为用户创建一个数据库(phplampDB)
mysql>create database phplampDB;
//授权phplamp用户拥有phplamp数据库(的)所有权限。
>grant all privileges on phplampDB.* to hbchen@localhost identified by 'hbchen';
//刷新系统权限表
mysql>flush privileges;
mysql>其它们操作
/*
如果想指定部分权限给一用户,可以这样来写:
mysql>grant select,update on phplampDB.* to hbchen@localhost identified by 'hbchen';
//刷新系统权限表。
mysql>flush privileges;
*/
3.删除用户。
@>mysql -u root -p
@>密码
mysql>Delete FROM user Where User="hbchen" and Host="localhost";
mysql>flush privileges;
//删除用户(的)数据库
mysql>drop database phplampDB;
4.修改指定用户密码。
@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password('新密码') where User="hbchen" and Host="localhost";
mysql>flush privileges;
5.列出所有数据库
mysql>show database;
6.切换数据库
mysql>use '数据库名';
7.列出所有表
mysql>show tables;
8.显示数据表结构
mysql>describe 表名;
9.删除数据库和数据表
mysql>drop database 数据库名;
mysql>drop table 数据表名;

 例如:--新建用户
insert into mysql.user(host,user,password) values ("localhost","hbchen",p
assword("hbchen"));
---授予权限
grant all privileges on mysql.* to hbchen@localhost identified by 'hbchen';
--授予部分权限
 grant select,update on mysql.* to hbhcen@localhost identified by 'hbchen';

--更改密码
update mysql.user set password='123456'where User='hbchen';

use mysql; 
update user set password=password('hahaha') where user='hbchen';
--刷新
flush privileges;

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted on 2011-08-28 21:04 Hukin 阅读(21689) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: