创建用户
使用MySQL的GRANT语句创建用户账户。以下是示例命令:
create user 'testUser'@'%' identified by 'TEST';
'%' 表示可以从任何主机访问数据库。
权限管理
为用户TEST@'%'授予数据库TEST的所有表权限:
grant all on TEST.* to 'testUser'@'%';数据库导入
将数据库导出到文件中:mysql test < /usr/test.sql数据库备份
使用mysqldump工具备份数据库结构和数据:
mysqldump -u username -p test > /usr/test.sql创建索引
在'uses'表中创建索引,命名为'user_sex_index',为'sex'字段创建索引:alter table uses add index user_sex_index(sex) comment '索引'sex'字段';查看表结构
查看表'offices'的创建语句:show create table offices;修改表结构
修改'offices'表中的'office_name'字段类型和注释:alter table offices modify office_name varchar(30) not null comment '科室名称';字符集设置
将'user_froms'表的字符集设置为utf8:alter table user_froms convert to character set utf8;