linux 安裝mysql和主從配置 + Spring 基於註解配置mysql讀寫分離

java_陳序猿發表於2017-07-24

1. 解除安裝已有的mysql 

http://www.cnblogs.com/kerrycode/p/4364465.html

2.  linux yum 安裝mysql 

http://www.cnblogs.com/sweet521/p/6196732.html

 

修改初始密碼

 

 grep 'temporary password' /var/log/mysqld.log   editPlus  sftp3 port22
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)

mysql> 
mysql> 
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file    |       |
| validate_password_length             | 3     |
| validate_password_mixed_case_count   | 0     |
| validate_password_number_count       | 3     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 0     |
+--------------------------------------+-------+
6 rows in set (0.00 sec)
4)修改簡單密碼:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

 

SET PASSWORD = PASSWORD('root');
 

grant all on *.* to 'root'@'%' identified by 'root' with grant option;

3. 主從配置 

 

http://www.cnblogs.com/alvin_xp/p/4162249.html

http://www.cnblogs.com/sustudy/p/4174189.html

配置master 

server-id=1   
log-bin=master-bin
binlog_checksum=none
log-bin-index=master-bin.index
binlog-do-db=business_maple     
binlog-ignore-db=mysql  

配置 slave :

[mysqld]
server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin

執行 一下程式碼

change master to master_host='192.168.0.104',master_port=3306,master_user='repl',master_password='mysql', master_log_file='master-bin.000001',master_log_pos=0;

start slave;

SpringMVC 基於註解 配置mysql 讀寫分離 + 德魯伊 + mybatis 

demo 原始碼下載地址:

http://download.csdn.net/download/maple980326/9977130

參考文件

http://www.cnblogs.com/surge/p/3582248.html

 

application xml 配置

 

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="false"/>

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="manyDataSourceAspect" class="com.maple.dynamic.DataSourceAspect" />
<aop:config>
<aop:aspect id="c" ref="manyDataSourceAspect" order="1">
<aop:pointcut id="tx" expression="execution(public * com.maple.dao.*.*(..))"/>
<aop:before pointcut-ref="tx" method="before"/>
</aop:aspect>
</aop:config>

 

 

 

 

 

 

 

 

 

 

相關文章