2008年8月31日星期日

Mysql常用命令及配置

  1. 创建用户
    格式:grant 权限1,权限2...(或*) on 数据库(或*).表名(或*) to 用户名@登录主机名("%"代表远程登录无限制) identified by '密码'
    例子:
              > grant * on *.* to xued@"%" identified by 'password' ;
              > flush privileges;
    注意以上方式创建的用户不能以localhost登录,必须使用mysql -u xued -h IP地址 -p 的方式登录。
    修改密码:
              > set password for 'xued'@'%' = password('********')

  2. 字符集及最大连接数
    修改my.cnf或my.ini,在[mysqd]下添加
    default-character-set=utf8
    character_set_server=utf8
    max_connections=100
    保存后重启。
    指定数据库的编码:
               > create database test charset utf8;
    jdbc的连接url参数添加字符集:jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf8


没有评论: