linux下的mysql调优_linux下mysql安装和调优

1.yum

yum -y install mysql-server mysql

2.RPM安装

http://dev.mysql.com/downloads/ 下载RPM包,请确认服务器版本,我的是红帽5.9,下载的是下面的版本,bundle是集合包

MySQL-5.6.21-1.rhel5.x86_64.rpm-bundle.tar

[root@localhost ~]# cd /soft/[root@localhost soft]# ll

总计608028

-rwxr--r-- 1 root root 310988800 10-18 13:28 MySQL-5.6.21-1.rhel5.x86_64.rpm-bundle.tar

-rw-r--r-- 1 7155 wheel 23156366 09-12 16:25 MySQL-client-5.6.21-1.rhel5.x86_64.rpm-rw-r--r-- 1 7155 wheel 4579502 09-12 16:25 MySQL-devel-5.6.21-1.rhel5.x86_64.rpm-rw-r--r-- 1 7155 wheel 117279604 09-12 16:26 MySQL-embedded-5.6.21-1.rhel5.x86_64.rpm-rw-r--r-- 1 7155 wheel 88524802 09-12 16:27 MySQL-server-5.6.21-1.rhel5.x86_64.rpm-rw-r--r-- 1 7155 wheel 2404168 09-12 16:27 MySQL-shared-5.6.21-1.rhel5.x86_64.rpm-rw-r--r-- 1 7155 wheel 75030266 09-12 16:28 MySQL-test-5.6.21-1.rhel5.x86_64.rpm

rpm -Uvh MySQL-*.rpm

mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('root');

Query OK,0 rows affected (0.07 sec)

3.mysql的基本命令和字段类型信息

show databses;

use mysql;

show tables;

describe user;

create database cms;

select database();

7cf16d56941a3f284df3c19c3e68f9ff.png

DATETIME(占8字节)

TIMESTAMP(占4字节)

DATE(占4字节)

YEAR(占1字节)

TIME(占3字节)

mysql> create table user1 select * from te where username='xx';

mysql> create table user2 select * from te where false

mysql> alter table te rename to user;

mysql> alter table file change guid gid int(10) not null;

mysql> load data infile '/etc/passwd' into table file fields terminated by ":" lines terminated by "\n";

mysql> alter table file drop column id;

mysql> alter table file add id int(10) unsigned not null auto_increment primary key(id) first;

mysql> select * from file into outfile "/soft/user.txt" fields terminated by "\t" lines terminated by "\n";

service mysql start --skip-grant-table&update mysql.user set password=password("123") where user='root'

mysqladmin -uroot -p password "1234"

GRANT all ON db.* TO dbuser@'%' IDENTIFIED BY 'password'

REVOKE all ON db.* FROM dbuser@'%'

flush privileges;

MySQL日志类型

1.错误日志:记录数据库服务启动,运行过程中产生的错误信息 默认开启

2.查询日志:记录登录用户执行的sql语句 默认不开启 /etc/my.cnf

general-log

3.慢查询日志:超时查询sql 默认不开启,默认超时10s

slow-query-log

slow-query-log-file=iflytek-slow-query.log

long-query-time=5

4.binlog日志:使数据发生改变的sql语句 默认不开启

打开/etc/my.cnf

log-bin=mysql-bin【默认名称可以不写】

mysqlbinlog -start-position=4 -stop-position=200 bin-log.000001 | mysql -uroot -proot

show binlog events

flush logs;

purge master logs to "iflytek-bin.000002" 删除002之前的binlog

reset master 重新设置binlog日志

【etc/my.cnf】

log-bin=/mysqldata/iflytek-bin

chown mysql /mysqldata/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值