安装// 安装 rpm -ivh MySQL_server_X.X.XX.linux2.6.x86_64.rpm // 启动 service mysql start // 停止 service mysql stop service mysql {start|stop|restart|reload|force-reload|status} /var/log/mysqld.log mysql -u root mysql -h <IP> -u <USERNAME> -p 查看版本: select version(); 存储引擎
维护
SQL
create database databasename; drop table if exists tablename; 锁
事务隔离级别 [4]
MySQL 默认是可重复读。 // 查看事务隔离级别 select @@tx_isolation; // 设置事务隔离级别 set session transaction isolation level READ UNCOMMITTED; 性能MySQL INSERT性能优化,将多条INSERT语句合并成一条INSERT语句,在事务中处理也会有性能提升。 INSERT INTO `insert_table` (`datetime`, `uid`, `content`, `type`) VALUES ('0', 'userid_0', 'content_0', 0); INSERT INTO `insert_table` (`datetime`, `uid`, `content`, `type`) VALUES ('1', 'userid_1', 'content_1', 1); 合并为: INSERT INTO `insert_table` (`datetime`, `uid`, `content`, `type`) VALUES ('0', 'userid_0', 'content_0', 0), ('1', 'userid_1', 'content_1', 1); 相关数据:
MySQL特殊点MySQL在执行UPDATE时,如果更新前和更新后数据一样时不会产生binlog日志,Oracle会产生日志 用户/权限CREATE USER 'username'@'%' IDENTIFIED BY 'password'; SHOW GRANTS FOR 用户名@域名或IP show grants for username; GRANT 权限列表 ON 数据库名.表名 TO 用户名@来源地址 [IDENTIFIED BY '密码'] grant select,insert,update,delete on schema.* to username@'%' identified by 'password'; REVOKE 权限列表 ON 数据库名.表名 FROM 用户名@域名或IP revoke ALL on schema.* from username@'%'; grant ALL PRIVILEGES on *.* to username@'%' identified by 'password' [WITH GRANT OPTION]. FLUSH PRIVILEGES; show [full] processlist; show variables; // 查看MySQL参数 函数STR_TO_DATE('2013-04-10 00:00:00', '%Y-%m-%d %H:%i:%s') String 转数字: cast(table_field as signed) 自增长IDMySQL中可以通过环境变量设置自增长ID的生成步长及起始值: SHOW VARIABLES LIKE 'auto_inc%'; auto_increment_increment auto_increment_offset 独立表空间innodb_file_per_table=1 The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC. Google MySQL: https://code.google.com/p/google-mysql/ http://www.mysqlperformanceblog.com/ 参考资料[1]. http://firedragonpzy.iteye.com/blog/1388562 |
||||||||||||||||||||||||||||||||||||||||