posts - 165, comments - 198, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

   这些日子一直在想,将来的我怎么在技术这条道路上好好走下去(这一辈子我都会干技术的,我相信我自己)。
    想着想着慢慢的开始害怕自己被淘汰。我才24岁就我工作的一年半中,就看到太多太多的技术被更替,被淘汰。又太多的新技术出现在我们面前。我这年努力去追赶(学习新技术就是一种投资^_^)
    应该要有些压箱底的东西!就今天开始先学数学;后数据结构;最后算法。我要把原来大学学的一点一点捡回来了。

学习之前给自己找个数学学习工具;
Scilab logo
scilab(开源) http://www.scilab.org/
       (参考)  http://blog.chinaunix.net/u/7217/article_40744.html
                http://blog.chinaunix.net/u1/56796/showart_694786.html
与之对应的 matlab(企业)对现在我来说太大了





scilab安装后运行
在命令行写入(运行后):
A=[1 2 3 4;5 6 7 8]

hist3d(A);





posted @ 2008-06-09 16:58 G_G 阅读(1891) | 评论 (3)编辑 收藏

就用数据数据库表地址数据(中国地区)来说吧
存储过程:
DELIMITER //
drop procedure if exists  useCursor //
create temporary table if not exists  aop.tmp_table(data bigint(20))//

//建立存储过程
CREATE PROCEDURE useCursor(iid bigint(20))
    
BEGIN
         //局部变量定义
         declare tid bigint(20default -1 ;
        
         //游标定义
         
declare cur1 CURSOR FOR select id from aop.location where fid=iid ;
        
//游标介绍定义
         declare
 CONTINUE HANDLER FOR SQLSTATE '02000' SET tid = null;
        
         //开游标
         OPEN cur1;
      
  FETCH cur1 INTO tid;

        
WHILE ( tid is not null ) 
         DO
          
insert into aop.tmp_table values(tid);
          //树形结构数据递归收集到建立的临时表中
          call useCursor(tid);
         
FETCH cur1 INTO tid ;
       
END WHILE;
    
END;//
DELIMITER ;

//查询开始 ,运行是成功的,但用时有10多秒之多,才几百条数据;
//望那个大牛 帮帮解决下时间问题!

call useCursor(
1);
select * from tmp_table ;
drop temporary table if  exists  aop.tmp_table ;


结果:

|  187 |
|  188 |
|  189 |
|  190 |
|  191 |
|  192 |
|  193 |
|  194 |
|  195 |
|  196 |
|  197 |
|  198 |
|  199 |
|  200 |
|  201 |
|  202 |
|  203 |
|  204 |
|  205 |
|  206 |
|  207 |
|  208 |
|  209 |
.

posted @ 2008-06-08 16:33 G_G 阅读(2768) | 评论 (2)编辑 收藏



     public   static  String filter(String input) {
        
if  (input  ==   null ) {
            
return   null ;
        }
        StringReader stringReader 
=   new  StringReader(input);
        BufferedReader reader 
=   new  BufferedReader(stringReader);

        StringBuffer ret 
=   new  StringBuffer(input.length()  +   200 ); //  add more room to the result String

        String line 
=   null ;
        
try  {
            //换行后添加<br/>
            
while  ((line  =  reader.readLine())  !=   null ) {
                //wap 对 <  >的替换
                ret.append(line.replaceAll(
" < " " &lt; " ).replaceAll( " > " " &gt; " ). replaceAll( "&""&amp;" ) ).append( " <br/>&nbsp;&nbsp; " );
            }
// while
            
// 如果是最后一行
        }  catch  (IOException ex) {}

       
return   " &nbsp;&nbsp; " + ret.toString() ;

    }

    

posted @ 2008-06-04 17:19 G_G 阅读(229) | 评论 (0)编辑 收藏

官方:
BaseX Logo
eg:xquery使用
import org.basex.core.Commands;
import org.basex.core.proc.Proc;
import org.basex.data.Result;
import org.basex.io.ConsoleOutput;
import org.basex.query.QueryException;
import org.basex.query.QueryProcessor;
import org.basex.query.xquery.XQueryProcessor;

/**
 * This class serves an example for executing XQuery requests.
 
*/
public final class XQueryExample {
  
/** Sample query. */
  
private static final String XMLFILE = XPathExample.class.getClassLoader().getSystemResource(
              
"xx.xml"
         ).getPath();
  
  
  
private static final String QUERY = " for $x in doc('"+XMLFILE+"')//property " +
                                              
" return <child>{data($x/@name)}</child>";

  
/** Private constructor. */
  
private XQueryExample() { }
  
/**
   * Main method of the example class.
   * 
@param args (ignored) command-line arguments
   * 
@throws Exception exception
   
*/
  
public static void main(final String[] args) throws Exception {

    
// FIRST EXAMPLE:
    System.out.println("First example:");

    
// create standard output stream
    final ConsoleOutput out = new ConsoleOutput(System.out);

    
// Create a BaseX process
    final Proc proc = Proc.get(Commands.XQUERY, QUERY);
    
// launch process
    if(proc.execute()) {
      
// successful execution: print result
      proc.output(out);
    } 
else {
      
// execution failed: print result
      proc.info(out);
    }
    out.flush();
    System.out.println();
    
    
// SECOND EXAMPLE (ALTERNATIVE):
    System.out.println("Second example:");

    
// Execute XQuery request
    try {
      
// create query instance
      final QueryProcessor xquery = new XQueryProcessor(QUERY);
      
// execute query; no initial context set is specified (null)
      final Result result = xquery.query(null);
      
// print output
      result.serialize(out, false);
      out.println();
    } 
catch(final QueryException e) {
      
// dump stack trace
      e.printStackTrace();
    }

    
// close output stream
    out.close();
  }
}


结果:
First example:
<child>connection.datasource</child>
<child>dialect</child>
<child>show_sql</child>
<child>hibernate.cache.provider_class</child>
<child>cache.use_query_cache</child>

Second example:
<child>connection.datasource</child>
<child>dialect</child>
<child>show_sql</child>
<child>hibernate.cache.provider_class</child>
<child>cache.use_query_cache</child>


数据来源:
xx.xml
<?xml version='1.0' encoding='utf-8'?>

<hibernate-configuration>

    
<session-factory>

        
<property name="connection.datasource">java:comp/env/jdbc/USERPORTAL1</property>
        
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
         
<property name="show_sql">true</property>
         
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
         
<property name="cache.use_query_cache">true</property>
    
<!-- JDBC connection pool (use the built-in) -->

    
</session-factory>

</hibernate-configuration>


posted @ 2008-06-04 16:04 G_G 阅读(1745) | 评论 (0)编辑 收藏

xml 数据库使用,和XQuery使用.
环境:
    1.xml数据库使用(参考:eXistQuick Start
    2.xQuery XQuery 首页
   
1.测试开始:
    进入:eXist-> http://demo.exist-db.org/xmldb/db/ 
for $x in doc("/examples2.xml")/exist:result/country return if ($x/population_growth<-1) then <child>{data($x/name)}</child> else <adult>{data($x/name)}</adult>
parent collection: /db
<child > Bosnia and Herzegovina </ child >
<adult > Czech Republic </ adult >
<child > Estonia </ child >
<child > Faroe Islands </ child >
<adult > Hungary </ adult >
<adult > Ireland </ adult >
<child > Latvia </ child >
<adult > Lithuania </ adult >
<child > Romania </ child >
<adult > Russia </ adult >

使用数据:
    http://demo.exist-db.org/xmldb/db/examples2.xml


2:自定义方法:
    使用:http://demo.exist-db.org/sandbox/sandbox.xql
   
declare function local:minPrice(){
  
for $x in (1 to 5)
  
return <test>{$x}</test>
};

<minPrice>{local:minPrice()}</minPrice>
结果:
<
minPrice>
<test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
</minPrice>




posted @ 2008-05-29 14:49 G_G 阅读(1160) | 评论 (1)编辑 收藏

     摘要: 为方便项目使用,特留!表结构:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> CREATE TABLE `location` (  `id` bigint(20) NOT NULL auto_increment,  `name` varchar(50...  阅读全文

posted @ 2008-05-29 10:51 G_G 阅读(5252) | 评论 (6)编辑 收藏

参考:第 9 章 事务管理 - Spring Framework reference 2.0.5 参考手册中文版
http://doc.javanb.com/spring-framework-reference-zh-2-0-5/ch09.html

先从配置文件开始:
源码:springAop.rar

需要jar
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    
<classpathentry kind="src" path="java"/>
    
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    
<classpathentry kind="lib" path="lib/aspectjrt.jar"/>
    
<classpathentry kind="lib" path="lib/aspectjweaver.jar"/>
    
<classpathentry kind="lib" path="lib/spring.jar"/>
    
<classpathentry kind="lib" path="lib/spring-sources.jar"/>
    
<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
    
<classpathentry kind="lib" path="lib/cglib-nodep-2.1_3.jar"/>
    
<classpathentry kind="lib" path="lib/hibernate3.jar"/>
    
<classpathentry kind="lib" path="lib/log4j-1.2.11.jar"/>
    
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
    
<classpathentry kind="lib" path="lib/commons-collections-2.1.1.jar"/>
    
<classpathentry kind="lib" path="lib/mysql.jar"/>
    
<classpathentry kind="lib" path="lib/jta.jar"/>
    
<classpathentry kind="lib" path="lib/antlr-2.7.6.jar"/>
    
<classpathentry kind="output" path="bin"/>
</classpath>


spring 配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop
="http://www.springframework.org/schema/aop"
    xmlns:tx
="http://www.springframework.org/schema/tx"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://www.springframework.org/schema/aop 
  http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
  http://www.springframework.org/schema/tx 
  http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
>

    
<!-- demo start -->
    
<import resource="demo_spring.xml" />
    
<!-- demo end -->

    
<bean id="dataSource"
        class
="org.springframework.jdbc.datasource.DriverManagerDataSource">
        
<property name="driverClassName"
            value
="com.mysql.jdbc.Driver">
        
</property>
        
<property name="url"
            value
="jdbc:mysql://localhost:3306/aop?characterEncoding=utf8">
        
</property>
        
<property name="username" value="root"></property>
        
<property name="password" value=""></property>
    
</bean>

    
<!-- hibernate3 sessionFactory  -->
    
<bean id="sessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<!-- 此次  为 spring 事务需要使用 dataSource ;为空事务由Hibernian自己维护 -->
        
<property name="dataSource" ref="dataSource" />
        
<property name="configLocation"
            value
="classpath:hibernate.cfg.xml" />
    
</bean>



    
<!-- 事务适配器 -->
    
<bean id="txManager"
        class
="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory" ref="sessionFactory" />
    
</bean>






    
<!-- aop 与事务联系 aopBean<->txAdvice  -->
    
<aop:config>
        
<!-- 逻辑拦截 -->
        
<aop:pointcut id="demoAopBean"
            expression
="execution(* demo*.*.*(..))" />
        
<aop:advisor advice-ref="demoTxAdvice"
            pointcut-ref
="demoAopBean" />
    
</aop:config>

    
<!-- 事务原子 具体方法进行什么事务 -->
    
<tx:advice id="demoTxAdvice" transaction-manager="txManager">
        
<tx:attributes>
            
<tx:method name="get*" propagation="SUPPORTS"
                read-only
="true" rollback-for="NoProductInStockException" />
            
<tx:method name="save*" propagation="REQUIRED"
                rollback-for
="NoProductInStockException" />
            
<tx:method name="update*" propagation="REQUIRED"
                rollback-for
="NoProductInStockException" />
            
<tx:method name="remove*" propagation="REQUIRED"
                rollback-for
="NoProductInStockException" />
            
<tx:method name="*" propagation="SUPPORTS"
                rollback-for
="NoProductInStockException" />
        
</tx:attributes>
    
</tx:advice>



    
<!-- daoCalss : extends HibernateDaoSupport implements BeanDao -->
    
<bean id="beanDao"
        class
="demo.springHibernate.dao.imp.BeanDaoImp">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory"></ref>
        
</property>
    
</bean>


    
<bean id="helloAction" class="demo.struts2Spring.HelloWorld"
        scope
="prototype">
        
<property name="bds" ref="beanDao"></property>
    
</bean>
    
</beans>


hibernate 配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
>
<hibernate-configuration>
<session-factory name="asdf">
    
<property name="hibernate.dialect">mysql</property>
    
<property name="myeclipse.connection.profile">
        com.mysql.jdbc.Driver
    
</property>
    
<property name="connection.url">
        jdbc:mysql://localhost/aop
    
</property>
    
<property name="show_sql">true</property>
    
    
<property name="connection.username">root</property>
    
<property name="connection.password"></property>
    
<property name="connection.driver_class">
        com.mysql.jdbc.Driver
    
</property>
    
<property name="dialect">
        org.hibernate.dialect.MySQLDialect
    
</property>
    
    
<mapping resource="bean/UnitBean.hbm.xml" />
    
</session-factory>
</hibernate-configuration>


dao 类(接口)
package dao.imp;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import bean.UnitBean;

import dao.BeanDao;

public class BeanDaoImp extends HibernateDaoSupport implements BeanDao{
    
public void addBean(UnitBean unitBean) {
        
this.getHibernateTemplate().save(unitBean);
    }

    
public List<UnitBean> getBeanByAll() {
        
return this.getHibernateTemplate().find(" from "+UnitBean.class.getName());
    }

    
public void removeBean(long beanId) {
        
this.getHibernateTemplate().delete(
                getHibernateTemplate().get(UnitBean.
class, beanId)
            );
    }
    
}

Main 类
package unit;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import dao.BeanDao;
import bean.UnitBean;

public class Main {
    
public static void main(String[] args) {
           ApplicationContext ctx 
= new ClassPathXmlApplicationContext("beans.xml");
           BeanDao dao 
= (BeanDao) ctx.getBean("beanDao");
           UnitBean bean 
= new UnitBean();
           bean.setName(
"xx");
           bean.setPass(
"11");
           dao.addBean(bean);
           
           
for(UnitBean unitBean : dao.getBeanByAll() ){
               System.out.println( unitBean.getId() );
           }
           
           dao.removeBean(bean.getId());
           
    }
}
结果:
Hibernate: insert into bean (name, pass) values (?, ?)
Hibernate: select unitbean0_.id as id0_, unitbean0_.name as name0_, unitbean0_.pass as pass0_ from bean unitbean0_
1
Hibernate: select unitbean0_.id as id0_0_, unitbean0_.name as name0_0_, unitbean0_.pass as pass0_0_ from bean unitbean0_ where unitbean0_.id=?
Hibernate: delete from bean where id=?






posted @ 2008-05-09 13:47 G_G 阅读(3137) | 评论 (0)编辑 收藏

我的aop 基础
spring 实际使用 (这就使用一个例子说明)

测试类以及结果:
package unit;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import bean.HelloService;

public class Main {
    
public static void main(String[] args) {
           ApplicationContext context 
= new ClassPathXmlApplicationContext(      
                   
"beans.xml");    
           HelloService service 
= (HelloService) context.getBean("helloService");    
           service.annotationAop();
           
           System.out.println();
           
           service.xmlAop();
           
    }
}
结果:
 annotationAop//正常方法运行
aop--AspectJ! //
annotation拦截

 xmlAop 
//正常方法运行
 aop--XmlAop! //配置拦截



use jar
  • --aspectjrt.jar
  • --aspectjweaver.jar
  • --acglib-nodep-2.1_3.jar
  • --commons-logging.jar
  • --spring.jar
  • --spring-aspects.jar
XML配置
<beans xmlns="http://www.springframework.org/schema/beans"       
            xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:aop
="http://www.springframework.org/schema/aop"
               xsi:schemaLocation
=        
                   "http://www.springframework.org/schema/beans         
                   http://www.springframework.org/schema/beans/spring-beans.xsd         
                   http://www.springframework.org/schema/aop         
                   http://www.springframework.org/schema/aop/spring-aop.xsd"
>
        
        
<!-- 测试使用类 分别由 方法 annotationAop/xmlAop -->
        
<bean id="helloService"       
            class
="bean.HelloService"/>    
        
            
        
<!-- annotation aop 拦截 使用@Aspect 
            @Pointcut("execution(* annotationAop(..))")  
            @AfterReturning("mainMethod()")  
        
-->
        
<bean id="xmlAop" 
            class
="aop.AnnotationAspectJ"/>
        
<aop:aspectj-autoproxy/>    
        
        
        
<!-- xml aop  配置文件拦截 -->
        
<bean id="XmlAspectJ"       
            class
="aop.XmlAspectJ"/>
        
<aop:config>     
             
<aop:aspect ref="XmlAspectJ">
                 
<aop:pointcut id="mainMethod" expression="execution(* xmlAop(..))"/>    
                 
<aop:after-returning pointcut-ref="mainMethod" method="goXmlAop"/>     
             
</aop:aspect>   
         
</aop:config>    
            
</beans>

HelloService.java
package bean;

public class HelloService {  
    
public void annotationAop() {    
        System.out.println(
" annotationAop ");
    }
    
    
public void xmlAop(){
        System.out.println(
" xmlAop ");
    }
}

AnnotationAspectJ.java
package aop;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class AnnotationAspectJ {  
    @Pointcut(
"execution(* annotationAop(..))")  
    
public void mainMethod() {}  
    
    @AfterReturning(
"mainMethod()")  
    
public void sayHello() {    
        System.out.println(
"aop--AspectJ!");  
    }
}

XmlAspectJ.java
package aop;

public class XmlAspectJ {
    
public void goXmlAop(){
        System.out.println(
" aop--XmlAop! ");
    }
}













posted @ 2008-05-08 10:08 G_G 阅读(4307) | 评论 (1)编辑 收藏

这就不介绍了 代码上:
package unit;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Assert;
import org.junit.Test;

public class RegexUnit {


    @Test
    
/**
     * <p>向前\向后查找</p>
     
*/
    
public void unit9()throws Exception{
        String testStr 
= "http://www.google.com";
        
        
/* 一般查找
         * .+(:) 查询出结果包含 :
         
*/
        Pattern pattern 
= Pattern.compile(".+(:)");        
        Matcher matcher 
=  pattern.matcher(testStr);
            Assert.assertTrue(
"错误: 查找出结果通过 .+(:) 此regex没有包含 : ",
                    matcher.find() 
&& matcher.group().equals("http:") );
        
        
/*  向前查找
         *  .+(?=:) 查询结果不包含 :
         
*/
        Pattern pattern2 
= Pattern.compile(".+(?=:)");
        Matcher matcher2 
= pattern2.matcher(testStr);
            Assert.assertTrue(
"错误: 查找出结果通过 .+(?=:) 此regex有包含 : ",
                    matcher2.find()
&& matcher2.group().equals("http"));
        
/* 向后查找
         * (?<=:).+
         
*/
        Pattern pattern3 
= Pattern.compile("(?<=://).+");
        Matcher matcher3 
= pattern3.matcher(testStr);
            Assert.assertTrue(
"错误:查找出结果包含 http:// 不向后查询",
                    matcher3.find()
&& matcher3.group().equals("www.google.com") );
    }


    @Test
    
/** 回朔应用 
     *  查询回朔、回朔替换、回朔大小写替换
     
*/
    
public void unit8()throws Exception{
        String testStr 
= "this is a block of of test,"+
                            
" several words here are are " +
                            
" repeated , and and they should not be. ";
        
        Pattern pattern 
= Pattern.compile("[ ]+(\\w+)[ ]+\\1");
        Matcher matcher 
= pattern.matcher(testStr);
        
//查询结果 are are 
        Assert.assertTrue("错误:regex 不匹配 "
                matcher.find()
&&matcher.group().split(" ").length>=2 );
        
        
while( matcher.find() ){
            Assert.assertTrue(
"错误:regex 不匹配 "
                    matcher.group().split(
" ").length>=2 );
        }
        
        
        
//替换
        String testStr2s = "313-555-1234";
        Pattern pattern2 
= Pattern.compile("(\\d{3})(-)(\\d{3})(-)(\\d{4})");
        Matcher mtmp 
=  pattern2.matcher(testStr2s);
        Assert.assertTrue(
"错误:没有查替换",
                mtmp.find() 
&& 
                    mtmp.replaceAll(
"($1) $3-$5").equals("(313) 555-1234") );
        
        
        
/*大小写替换(java 不能成功)
         *  \E 结束 \L 或 \U转换
         *  \l  \L 把下一个字符(串)换为小写
         *  \ u  \U 把下一个字符(串)转换为大写
         *  此中
(.*?)懒散加载
         */
        String testStr3 
= "tt:google:xx";
        Pattern pattern3 
= Pattern.compile("(?<=:)(.*?)(?=:)");
        Matcher matcher2 
= pattern3.matcher(testStr3);
        
if( matcher2.find())
            System.out.println( matcher2.group() ) ;
    }
    
    
}



posted @ 2008-05-04 09:59 G_G 阅读(2250) | 评论 (3)编辑 收藏

MySQL 存取控制包含2个阶段:

  • 阶段1:服务器检查是否允许你连接。
  • 阶段2:假定你能连接,服务器检查你发出的每个请求。看你是否有足够的权限实施它。例如,如果你从数据库表中选择(select)行或从数据库删除表,服务器确定你对表有SELECT权限或对数据库有DROP权限。
参考 : 5.8. MySQL用户账户管理

1.权限查看
mysql> show grants for 'root'@'localhost' ;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.06 sec)

2.权限设置
5.8.2. 向MySQL增加新用户账户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    
->     IDENTIFIED BY 'some_pass';

mysql
> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    
->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
   其中两个账户有相同的用户名monty和密码some_pass。两个账户均为超级用户账户,具有完全的权限可以做任何事情。一个账户 ('monty'@'localhost')只用于从本机连接时。另一个账户('monty'@'%')可用于从其它主机连接。


mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
该账户只用于从本机连接。授予了RELOADPROCESS管理权限。这些权限允许admin用户执行mysqladmin reloadmysqladmin refreshmysqladmin flush-xxx命令,以及mysqladmin processlist。未授予访问数据库的权限。你可以通过GRANT语句添加此类权限。

mysql
> GRANT USAGE ON *.* TO 'dummy'@'localhost';
    一个账户有用户名dummy,没有密码。该账户只用于从本机连接。未授予权限。通过GRANT语句中的USAGE权限,你可以创建账户而不授予任何权限。它可以将所有全局权限设为'N'。假定你将在以后将具体权限授予该账户。

下面的例子创建3个账户,允许它们访问专用数据库。每个账户的用户名为custom,密码为obscure

mysql
> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    
->     ON bankaccount.*
    
->     TO 'custom'@'localhost'
    
->     IDENTIFIED BY 'obscure';

mysql
> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    
->     ON expenses.*
    
->     TO 'custom'@'whitehouse.gov'
    
->     IDENTIFIED BY 'obscure';

mysql
> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    
->     ON customer.*
    
->     TO 'custom'@'server.domain'
    
->     IDENTIFIED BY 'obscure';

这3个账户可以用于:

·         第1个账户可以访问bankaccount数据库,但只能从本机访问。

·         第2个账户可以访问expenses数据库,但只能从主机whitehouse.gov访问。

·         第3个账户可以访问customer数据库,但只能从主机server.domain访问。

要想不用GRANT设置custom账户,使用INSERT语句直接修改 授权表:

5.8.3. 从MySQL删除用户账户

DROP USER user;




posted @ 2008-04-29 13:52 G_G 阅读(11649) | 评论 (3)编辑 收藏

仅列出标题
共16页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last