主题搜索 全文搜索
热点问题
帮助流程
如果在使用我们的产品中遇到问题,建议您在“常见问题”中查询解决方法;
如果没有找到该问题的解决方法,您可以在“问题搜索”中进行搜索;
如果搜索后没有找到满意答案,您可以“在线客服”,我们会尽快给您答复。
MySql常用命令
作者:客服中心 文章来源:八联网络科技 更新时间:2015-06-29
// 启动服务 // 停止服务
mysqladmin -u root shutdown // 登录后使用数据库 mysql
mysql -u root -p mysql mysql -u root -p -h 11.11.11.11 database // 创建数据库
create database db_name [default character set=gbk] // 设置数据库默认字符集
alter databse db_name default character set gbk // 更换数据库 use database test after log on
use test // 创建一个带图像字段的表 create a table mypic to store picture
create table mypic (picid int, picname varchar(20), content blob); // 显示表的结构 describe table mypic
desc mypic // 显示当前表的建表语句
show create table table_name // 更改表类型
alter table table_name engine innodb|myisam|memory // 插入一条记录 insert a record
insert into mypic values (1, ’第二章’, 0x2134545); // 显示当前用户 show current user
select user(); // 显示当前用户密码 show current password
select password(’root’); // 显示当前日期 show current date
select now(); // 更改用户密码 change user password
update user set password=password(’xxx’) where user=’root’; // 分配用户权限 grant
grant all privileges on *.* to root@localhost grant select,insert,delete,update,alter,create,drop on lybbs.* to lybbs@"%" identified by "lybbs"; grant select,insert,delete,update,alter,create,drop on lybbs.* to lybbs@localhost identified by "lybbs";
// 向表中增加一个主键 add primary key
alter table mypic add primary key (picid) // 修改表结构增加一个新的字段 add a new column userid after picid
alter table mypic add column userid int after picid // 更改列类型,当存储图像过大时,使用默认blob超不过100k
alter table userpic change image image longblob; alter table userpic modify image longblob; // 设置默认字符集为gb2312
mysqld --default-character-set=gb2312 // 显示详细信息,包括字符集编码
show full columns from userpic; // 改变表的编码
ALTER TABLE userpic CHARACTER SET gb2312; // mysql jdbc连接url 使用中文
jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gb2312 // 执行外部脚本
source <filename> MySQL是最受欢迎的开源SQL数据库管理系统,由MySQL AB开发、发布和支持。MySQL AB是一家基于MySQL开发人员的商业公司,是一家使用了一种成功的商业模式来结合开源价值和方法论的第二代开源公司。MySQL是MySQL AB的注册商标。
|
上一个文章:编辑web.config,保证ASP.NET的安全
下一个文章:ASP使用Access数据库的安全隐患及对策