- 浏览: 25744 次
- 性别:
- 来自: 广州
最新评论
文章列表
MySQL是开源的关系型数据库系统。复制(Replication)是从一台MySQL数据库服务器(主服务器master)复制数据到另一个服务器(从服务器slave)的一个进程。
配置主服务器(master)
1、编辑数据库配置文件my.cnf,一般在/etc/目录下。
#vi /etc/my.cnf
在[mysqld]的下面加入下面代码:
log-bin=mysql-bin
server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
binlog-do-db=wordpress
binlog_ignore_db=mysql
ser ...
[1] Install AWstats
[root@www03 ~]#yum -y install awstats
[root@www03 ~]#vi /etc/awstats/awstats.www03.server.world.conf # this file is already locate (replace your server's name)
# line 122: change
# if your config for log format in httpd.conf is 'combined' Set here '1'
# If log-config is 'comm ...
MySQL默认字符编码为latin1,因此用Grails写入数据时会导致乱码,修改方式为:
/etc/init.d/mysql start (stop) 为启动和停止服务器
/etc/mysql/ 主要配置文件所在位置 my.cnf
/var/lib/mysql/ 放置的是数据库表文件夹,这里的mysql相当于windows下mysql的date文件夹
启动mysql后,以root登录mysql
$ mysql -u root
>show variables like 'character%'; #执行编码显示
+--------------------------+---------- ...
Grails可以自动把params里面的参数绑定到domain class。有些时候为了能够绑定自定义的日期格式,例如"yyyy-MM-dd",需要register一个自己的CustomDateEditor。
有时候还有需求要绑定多种格式的日期,例如"yyyy/MM/dd"、"yyyy-MM-dd HH:mm:ss"等等,这时候就需要一个支持多种日期格式的CustomDateEditor,解决方法如下:
1. 新建一个MultipleDateEditor.groovy
package com.myapp
import java ...
It has been possible to bind a date directly since long before Grails 1.3. The steps are:
(1) Create a class that registers an editor for your date format under grails-app/utils:
import org.springframework.beans.PropertyEditorRegistrar
import org.springframework.beans.PropertyEditorRegistry
impor ...
在使用grails spring security core plugin时,实现用户登录的时候更新上次登录时间
在Config.groovy添加如下代码:
import com.myapp.User
grails.plugins.springsecurity.useSecurityEventListener = true
grails.plugins.springsecurity.onInteractiveAuthenticationSuccessEvent = { e, appCtx ->
User.withTransaction {
def u ...
1. Implement the first requirement – Add an email address property to the user domain
This is really simple, just add the property to the domain class
package org.customauth
class CustomUser {
String username
String password
String email
boolean enabled
boolean acco ...
Ever needed to run an existing java web application side by side with your grails project? I found myself in exactly that position this week, and discovered that it (like most things in grails) was rather simple to accomplish. Considering I work in a predominately Java environment, I often need to ru ...
在Fedora 14了安装了subversion,不想直接简单的写到启动脚本里启动,于是google到下面的脚本了,毕竟用chkconfig和service命令更方便。
本脚本能让subversion作为一个守护进程启动。
vi /etc/init.d/subversion
#!/bin/bash
#
# /etc/rc.d/init.d/subversion
#
# Starts the Subversion Daemon
#
# chkconfig: 2345 90 10
# description: Subversion Daemon
# processnam ...
这里涉及的配置方式主要是使用 .htaccess 文件, 要使用.htaccess文件,则必须设置服务器以允许在这些文件中使用认证指令,即用AllowOverride指令指定哪些指令在针对单个目录的配置文件中有效。首先将对应的AllowOverride这样设置:
...
I recently had to execute some SQL scripts when a Grails applications starts up to insert test data into the database.
Executing sql scripts is easy. Just open the SQL File and read the contents of the Script to a String variable.
String sqlFilePath = 'path/to/your/script.sql'
String sqlString = new ...
By now, you’re probably under the impression that I love Grails, and you wouldn’t be far off from the truth. Ever since I started using it almost a year ago, I’ve continually been amazed by just how darn productive I can be. One of the aspects I want to touch on today is how Grails helps you build ri ...
Logging informational messages from a controller or service is the sort of thing I wish I'd figured out how to do when I first started playing around with Grails. All the information is in the docs, but it took me a while to find it and it could be a bit obscure for someone just getting started.
Her ...
grails的datePicker标签很好,但是并不能设置成yyyy-MM-dd的格式,另外,在月份选择列表中,显示的是中文的:一月、二月等等,对于追求简捷的中国人来说,这不符合我们的习惯。怎么办?
在grails英文指南页面中,显示了它的源代码位置在:/grails/src/groovy/org/codehaus/groovy/grails/plugins/web/taglib/FormTagLib.groovy
因此,在www.grails.org把源代码下载下来,按照路径找到这个FormTagLib.groovy文件,把里面关于datePicker的一节复制下来,在自己所做项目的tagl ...
1.悲观锁
它指的是对数据被外界修改持保守态度。假定任何时刻存取数据时,都可能有另一个客户也正在存取同一笔数据,为了保持数据被操作的一致性,于是对数据采取了数据库层次的锁定状态,依靠数据库提供的锁机制来实现。
基于jdbc实现的数据库加锁如下:
select * from account where name="Erica" for update
在更新的过程中,数据库处于加锁状态,任何其他的针对本条数据的操作都将被延迟。本次事务提交后解锁。
而hibernate悲观锁的具体实现如下:
String sql="查询语句";
Query qu ...