4 回答
TA贡献1797条经验 获得超4个赞
1、用管理员登陆mysql
2、创建数据库create database db01;
3、创建用户
user01只能本地访问
CREATE USER user01@'localhost' IDENTIFIED BY 'password1';
user02可以远程访问
CREATE USER user02@'%' IDENTIFIED BY 'password1';
4、修改user01密码
SET PASSWORD FOR 'user01'@'localhost' = PASSWORD('password2');
5、授权
a)、user01管理db01全部权限
GRANT ALL PRIVILEGES ON db01.* TO user01;
b)、user02查看权限,并修改密码
GRANT SELECT ON *.* TO 'user02'@'%' IDENTIFIED by 'password2';
TA贡献1784条经验 获得超9个赞
新建普通用户:CREATE USER 'test1'@'localhost' IDENTIFIED BY 'test1'
数据库创建:CREATE DATABASE example
表的创建:CREATE TABLE example0(id INT,
name VARCHAR(20),
sex BOOLEAN
)
TA贡献1805条经验 获得超9个赞
DROP DATABASE IF EXISTS userdb;
CREATE DATABASE userdb;
USE userdb;
CREATE TABLE user(
id int(11)NOT NULL AUTO_INCREMENT,
userName varchar(20) DEFAULT NULL,
userPwd varchar(20) DEFAULT NULL,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO user(id,userName,userPwd)VALUES(1,'admin','admin');
添加回答
举报