给数据库表格中的字段做加密处理
方式一:
利用外部加密算法对要加密的字段值进行加密后,然后将该条记录插入表格中。如若要比较该字段值与表格中的某条记录是否相同,对要比较的值按照同样的方式进行加密后,再去与表格中的字段对比
对存储在数据库中的密码安全性要求高的话,可采用MD5加密方式,该加密是不可逆的,很难破解
方式二:
利用MySql提供的加密-解密函数:AES_ENCRYPT() 和AES_DECRYPT().
eg-插入加密数据: insert into t_user(name,pwd,authority) values("test",AES_ENCRYPT("123456","key"),1);
eg-取出解密数据: select AES_DECRYPT(pwd,"key") from t_user where name="test";
缺点:使用这种可逆加密方式加密过的数据,只要知道秘钥容易被解密;不适用与对加密要求高的。
MySql配置文件分析
路径:
安装路径\MySQL\MySQL Server 5.5\my.ini 。此文件是在配置完MySql server之后生成的
内容:
- default-storage-engine=INNODB
innodb,MySql的数据库引擎之一
- max_connections
允许最大的并发连接数
- query_cache_size
Query cache is used to cache SELECT results and later return them without actual executing the same query once again。存放查询结果的缓存空间。
- table_cache
The number of open tables for all threads。(?)
- tmp_table_size
Maximum size for internal (in-memory) temporary tables
- thread_cache_size
How many threads we should keep in a cache for reuse。保存client threads的缓存空间
- innodb_additional_mem_pool_size
存储元数据的内存池大小。如果缓存元数据的空间不够,会向系统申请。
- innodb_log_buffer_size
缓存log数据的空间
- innodb_buffer_pool_size
to cache both indexes and row data. The bigger you set this the less disk I/O is needed to access data in tables.