mysql新加入用户与删除用户详细操作命令
方法1 :使用mysql root(root权限)用户登陆直接赋权也能够创建用户
/usr/bin/mysqladmin -u root password 123456
mysql -uroot -p
password
查看全部username与password
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;;
更改数据库password
user mysql
改动mysql数据库的password
UPDATE user SET Password=PASSWORD('123456') where USER='root';
mysql rootpassword为空 登陆的时候不须要password
UPDATE user SET Password=PASSWORD(null) where USER='root';
flush privileges;
方法二:
1.新建用户。
//登录MYSQL
@>mysql -u root -p
@>password
//首先为用户创建一个数据库(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 password为:1234 的用户。
然后登录一下。
mysql>exit;
@>mysql -u phplamp -p
@>输入password
mysql>登录成功
2.为用户授权。
格式:grant 权限 on 数据库.* to username@登录主机 identified by "password";
>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
@>password
mysql>DELETE FROM user WHERE User="test" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database testDB;
4.改动指定用户password。
@>mysql -u root -p
@>password
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 username@'%';
>drop user username@ localhost;
mysql新加入用户与删除用户详细操作命令的更多相关文章
- MySQL添加用户、删除用户与授权
MySql中添加用户,新建数据库,用户授权,删除用户,修改密码(注意每行后边都跟个;表示一个命令语句结束): 1.新建用户 1.1 登录MYSQL: @>mysql -u root -p @&g ...
- MySql安装与MySQL添加用户、删除用户与授权
1.安装MySql 目前MySQL有两种形式的文件,一个是msi格式,一个是zip格式的.msi格式的直接点击setup.exe就好,按照步骤进行.但是很多人下了zip格式的解压发现没有s ...
- MySql添加用户,新建数据库,用户授权,删除用户,修改密码
转自:http://www.cnblogs.com/fly1988happy/archive/2011/12/15/2288554.html MySql中添加用户,新建数据库,用户授权,删除用户,修改 ...
- centos的用户、组权限、添加删除用户等操作的详细操作命令
1.Linux操作系统是多用户多任务操作系统,包括用户账户和组账户两种 细分用户账户(普通用户账户,超级用户账户)除了用户账户以为还 有组账户所谓组账户就是用户账户的集合,centos组中有两种类型, ...
- 转载:mysql添加用户、删除用户、授权、修改密码
mysql添加用户.删除用户.授权.修改密码等 MySql中添加用户,新建数据库,用户授权,删除用户,修改密码1.新建用户. //登录MYSQL @>mysql -u root -p @> ...
- 【转】【Mysql】MySQL添加用户、删除用户与授权
MySql中添加用户,新建数据库,用户授权,删除用户,修改密码(注意每行后边都跟个;表示一个命令语句结束): 1.新建用户 1.1 登录MYSQL: @>mysql -u root -p @&g ...
- mysql添加,授权,删除用户以及连接数据库Can't connect to MySQL server on '192.168.31.106' (113)错误排查
centos7下面操作mysql添加,授权,删除用户 添加用户 以root用户登录数据库,运行以下命令: create user test identified by '; 上面创建了用户test,密 ...
- MySql5.7创建数据库与添加用户、删除用户及授权
MySql安装启动成功后(不会的可以查看上篇MySql5.7安装及配置),首先我们需要创建数据库,然后创建一个用户去操作这个数据库: 一.创建数据库 在MySql命令行中输入: create data ...
- linux创建用户、设置密码、修改用户、删除用户
创建用户.设置密码.修改用户.删除用户:useradd testuser 创建用户testuserpasswd testuser 给已创建的用户testuser设置密码说明:新创建的用户会在/home ...
- useradd adduser linux创建用户、设置密码、修改用户、删除用户
创建用户.设置密码.修改用户.删除用户: useradd testuser 创建用户testuser passwd testuser 给已创建的用户testuser设置密码 说明:新创建的用户会在/h ...
随机推荐
- Lesson 2 Building your first web page: Part 1
In this ‘hands-on’ module we will be building our first web page in no time. We just need to quickly ...
- Lesson 2 Building your first web page: Part 3
Time to build your first HTML page by hand I could go on with more theory and send half of you to sl ...
- 125.C++输入小结
#include <iostream> #include <iomanip> #include <cstring> #include <cstdlib> ...
- 123.static静态函数与类模板
#include <iostream> using namespace std; //静态函数没有this指针,无需创建对象就可以直接调用 template<class T> ...
- 104.virtual虚函数多态与异构数据结构
#include "mainwindow.h" #include <QApplication> #include <list> #include <Q ...
- android学习笔记五。2、其他组件
一.ContentProvider内容提供者.是是android中一个应用向第三方共享数据的方式,android中的联系人,sms(短信记录)等都是通过这一方式来向外提供的 1.使用: 在应用中使用C ...
- Mysql source导入.sql文件深坑!
刚刚接手一个项目,给老系统加功能.把数据库考出来一个.sql文件就170多M. 使用mysql命令行source 我的.sql文件. 导了一宿都没导完,然后发现里面的数据怎么是乱码呢.. 崩溃额,在排 ...
- 昼猫笔记 JavaScript -- 作用域技巧!!
简单理解 var zm = function (x) { var code = 'bb' return code }; 学过js的老哥们都知道,当这样简单的一个函数进入浏览器,浏览器开始解释代码,会将 ...
- centos yum 安装php7.2
yum -y remove php* rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm r ...
- [Python] Slicing Lists
In addition to accessing individual elements from a list we can use Python's slicing notation to acc ...