易截截图软件、单文件、免安装、纯绿色、仅160KB

MySQL命令

1. 连接mysql:
mysql -h 主机地址 -u 用户名 -p
2.退出mysql:exit
3. 修改密码:
mysqlbinmysqladmin -uroot -p(oldpassword) password newpassword
4.增加用户:
添加一个用户test1 密码为ABC;让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入
mysql,然后键入以下命令:grant select,insert,update,delete on *.* to test1@"%" Identified
by "abc";
增加一个用户test2密码为abc,让其只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作(localhost指本地
主机,即mysql数据库所在的那台主机),这样用户即使用知道test2的密码,也无法从internet上直接访问数据库,只能通过mysql主机上的web页
来访问了。grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
增加一个可以从任何地方连接服务器的一个完全的超级用户
grant all privileges on *.* to test3@"%" identified by 'password' with grant option;
5.删除授权
revoke select,insert,update,delete om *.* from test2@localhost ;
--------------------------------------------------------
6.显示数据库
show databases;
7.显示数据库中的表
use dataname;
show tables;
8.显示表的结构
describe tablesname;
9.建库
create database 库名;
10.建表
use dataname;
create table teacher //建立表TEACHER
(
id int(3) auto_increment not null primary key,
name char(10) not null,
address varchar(50) default '深圳',
year date
); //建表结束
//以下为插入字段
insert into teacher values('','glchengang','深圳一中','1976-10-10');
insert into teacher values('','jack','深圳一中','1975-12-23');
注:在建表中
(1) 将ID设为长度为3的数字字段:int(3),并让它每个记录自动加一: auto_increment,
并不能为空:not null,而且让它成为主字段primary key
(2) 将NAME设为长度为10的字符字段
(3) 将ADDRESS设为长度50的字符字段,而且缺省值为深圳。varchar和char有什么区别
呢,只有等以后的文章再说了。
(4) 将YEAR设为日期字段。
如果你在mysql提示符键入上面的命令也可以,但不方便调试。 你可以将以上命令
原样写入一个文本文件中假设为school.sql,然后复制到c:下,并在DOS状态进入目录
mysql in,然后键入以下命令


相关文档:

Mysql数据库导出方法

导出整个数据库:mysqldump -u用户名 -p密码 需要导出的数据库名 > 导出文件名.sql
其他参数:
-d 不包含数据,只有数据库表结构
--add-drop-table 在每个create语句之前增加一个drop
--skip-opt 每条记录只对应一个insert语句 ......

MYSQL数据库优化摘录

1、选取最适用的字段属性
  MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使 ......

Quick Test Setup of MySQL Cluster


To familiarize you with the basics, we will describe the simplest
possible configuration for a functional MySQL Cluster. After this,
you should be able to design your desired setup from the
information provided in the other relevant sections of this
chapter.
......

Java+Mysql的数据库查找实现


public class select {
 public List XiuGai_select(String keyword){
  List list=new ArrayList();
        Connection conn = null;
  Statement stmt = null;
  String sql=null;
  ResultSet res = null;
  get ......

mysql的三种安装方式

安装的OS为Solaris10,mysql 版本是5.1.38
一、使用RPM包进行安装

    首先可以从安装光盘中或者到mysql的网站上下载对应版本的rpm包如下:
MySQL-server-community-5.1.38-0.rhel5.i386.rpm
MySQL-client-community-5.1.38-0.rhel5.i386.rpm
    接着我们可以使用rpm命 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号