欢迎投稿

今日深度:

mysql新添加用户与删除用户具体操作命令,mysql具

mysql新添加用户与删除用户具体操作命令,mysql具体操作


方法1 :使用mysql root(root权限)用户登陆直接赋权也可以创建用户
/usr/bin/mysqladmin -u root password 123456



mysql -uroot -p
密码
查看所有用户名与密码
select host ,user ,password from user;



grant all on ec.* to 'root'@'%'  identified by '123456';
grant all privileges on ec.* to 'cockpit'@'%'  identified by '123456';
grant all on ec.* to 'cockpit'@'%'  identified by '123456';
grant all privileges on ec.* to 'cockpit'@'%'  identified by '123456';
flush privileges;;

更改数据库密码
user mysql

修改mysql数据库的密码
 UPDATE user SET Password=PASSWORD('123456') where USER='root';
mysql  root密码为空  登陆的时候不需要密码
UPDATE user SET Password=PASSWORD(null) where USER='root';
flush privileges;

方法二:
1.新建用户。
//登录MYSQL
@>mysql -u root -p
@>密码
//首先为用户创建一个数据库(testDB)
mysql>create database testDB  default character set utf8;;
//创建用户
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
//刷新系统权限表
mysql>flush privileges;
这样就创建了一个名为:test  密码为:1234  的用户。
然后登录一下。
mysql>exit;
@>mysql -u phplamp -p
@>输入密码
mysql>登录成功
2.为用户授权。
    格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"; 
    >grant all privileges on phplampDB.* to phplamp@localhost identified by '1234";

    授权test用户拥有所有数据库的某些权限:  
  mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

     //test用户对所有数据库都有select,delete,update,create,drop 权限。

  //@"%" 表示对所有非本地主机授权,不包括localhost。(localhost地址设为127.0.0.1,如果设为真实的本地地址,不知道是否可以,没有验证。)

//对localhost授权:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。



3.删除用户。
@>mysql -u root -p
@>密码
mysql>DELETE FROM user WHERE User="test" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database testDB;
4.修改指定用户密码。
@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password('新密码') where User="test" and Host="localhost";
mysql>flush privileges;


delete from  user where User="test" and Host="localhost";


也可以试试:

删除账户及权限:>drop user 用户名@'%';

        >drop user 用户名@ localhost;


登录数据库,输入:show databases; 显示mysql、test, 再用grant命令增加用户A并赋予权限 怎删除A用户

mysql是系统数据库,user表是授权表
你删除了A的话,授权表里就不存在A用户了
当然你如果直接修改的user表的话要刷新授权,修改才会生效,刷新方法楼上说过了
 

MySQL怎授权一个自己的创建的用户比如daitest创建新数据库的权利?命令

慢慢看吧
mysql中可以给你一个用户授予如select,insert,update,delete等其中的一个或者多个权限,主要使用grant命令,用法格式为:
grant 权限 on 数据库对象 to 用户
一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一条 mysql 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’

二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 mysql 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; - now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; - now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;

三、grant 普通 dba 管理某个 mysql 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。

四、grant 高级 dba 管理 mysql 中所有数据库的权限。
grant......余下全文>>
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/4181.html NewsArticle mysql新添加用户与删除用户具体操作命令,mysql具体操作 方法1 :使用mysql root(root权限)用户登陆直接赋权也可以创建用户 /usr/bin/mysqladmin -u root password 123456 mysql -uroot -p 密码 查看所有用...
评论暂时关闭