登陆命令:mysql -u(用户名) -p(密码)
创建数据库: create database uisftech default character set utf8 collate utf8_general_ci;
create database uisftech character set utf8;
创建的用户名为:uisftech、密码为: uisftech 、具备访问uisftech数据库的本地用户,以超级用户(root)的身份登录到MySQL控制台:
grant all privileges on *.* to uisftech@localhost identified by 'uisftech';
刷新系统权限表:flush privileges;
如果要创建相同的远程用户,可执行语句:
grant all privileges on *.* to 'uisftech'@'%' identified by 'uisftech';
首先为用户创建一个数据库(uisftech)
create database uisftech;
授权phplamp用户拥有phplamp数据库的所有权限:
grant all privileges on uisftech.* to uisftech@localhost identified by 'uisftech';
如果想指定部分权限给一用户,可以这样来写:
grant select,update on uisftech.* to uisftech@localhost identified by 'uisftech';
删除用户:
DELETE FROM user WHERE User="uisftech" and Host="localhost";
修改指定用户密码:
update mysql.user set password=password('新密码') where User="uisftech" and Host="localhost";
转到数据库:use uisftech;
查询数据库中所有表:show tables;
在windows控制台执行SQL文件:mysql uisftech -u(用户名) -p(密码) [-D(数据库)] < (脚本绝对路径)
在mysql控制台执行SQL文件:source (脚本绝对路径)
创建表:
建立一个相同结构的表: create table UserInfo like User;
create table UserInfo (select * from User);
查询表的创建sql:show create table User;
查看表结构: desc User;
查看数据库编码:show variables like 'char%';
设置MySql客户端编码: set character_set_client=GBK;
设置MySql客户端编码: set character_set_server=utf8;
#<!-- 驱动 -->
driverlass=com.mysql.jdbc.Driver
#<!-- jdbc url -->
url=jdbc:mysql://localhost:3306/uisftech
创建数据库: create database uisftech default character set utf8 collate utf8_general_ci;
create database uisftech character set utf8;
创建的用户名为:uisftech、密码为: uisftech 、具备访问uisftech数据库的本地用户,以超级用户(root)的身份登录到MySQL控制台:
grant all privileges on *.* to uisftech@localhost identified by 'uisftech';
刷新系统权限表:flush privileges;
如果要创建相同的远程用户,可执行语句:
grant all privileges on *.* to 'uisftech'@'%' identified by 'uisftech';
首先为用户创建一个数据库(uisftech)
create database uisftech;
授权phplamp用户拥有phplamp数据库的所有权限:
grant all privileges on uisftech.* to uisftech@localhost identified by 'uisftech';
如果想指定部分权限给一用户,可以这样来写:
grant select,update on uisftech.* to uisftech@localhost identified by 'uisftech';
删除用户:
DELETE FROM user WHERE User="uisftech" and Host="localhost";
修改指定用户密码:
update mysql.user set password=password('新密码') where User="uisftech" and Host="localhost";
转到数据库:use uisftech;
查询数据库中所有表:show tables;
在windows控制台执行SQL文件:mysql uisftech -u(用户名) -p(密码) [-D(数据库)] < (脚本绝对路径)
在mysql控制台执行SQL文件:source (脚本绝对路径)
创建表:
create table if not exists Employee(
EmployeeID varchar(6) primary key,
Name varchar(20) not null,
IDNumber varchar(18) not null unique,
Birthday date not null,
Gender int(1) not null
);
create table if not exists UserGroup(
UserGroupID varchar(1) primary key,
UserGroupName varchar(20) not null
);
create table if not exists User(
UserName varchar(20) primary key,
Password varchar(20) not null,
EmployeeID varchar(6) not null,
UserGroupID varchar(1) not null,
Status int(1) not null ,
constraint fk_User_EmployeeID foreign key (EmployeeID) references Employee(EmployeeID) -- 表中创建外键
);
-- 表外创建外键
alter table User add constraint fk_User_UserGroupID foreign key (UserGroupID) references UserGroup(UserGroupID);
-- 创建索引
alter table Employee add index index_employee_name ( Name );
建立一个相同结构的表: create table UserInfo like User;
create table UserInfo (select * from User);
查询表的创建sql:show create table User;
查看表结构: desc User;
查看数据库编码:show variables like 'char%';
设置MySql客户端编码: set character_set_client=GBK;
设置MySql客户端编码: set character_set_server=utf8;
#<!-- 驱动 -->
driverlass=com.mysql.jdbc.Driver
#<!-- jdbc url -->
url=jdbc:mysql://localhost:3306/uisftech