时间:2021-07-01 10:21:17 帮助过:27人阅读
[mysqld]
server-id=1
log-slow-queries=mysql-slow.log
log-error=mysql.err
log=mysql.log
log-bin=mysql-bin
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
从服务器my.cnf配置
[mysqld]
port=3306
server-id=2
expire_logs_day=7
log-slow-queries=mysql-slow.log
log-error=mysql.err
log=mysql.log
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#character-set-server = utf8
#collation-server =utf8_general_ci 此行和上一行为改变编码为UTF8 ,
#如果要改的话一定要注意所有的编码都要改
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
5.mysql服务器备份(主服务器)#mysqldump -uroot -pmysql test -l -F '/tmp/test.sql'此命令备份不用另外读锁
mysql> show slave status/G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.100.206
Master_User: user1
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 262
Relay_Log_File: mysqld-relay-bin.000006
Relay_Log_Pos: 407
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes #这两行YES代表成功了
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 262
Relay_Log_Space: 708
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
以下为用到的一些命令及笔记
mysql> insert into t1 values(4),(5),(6),(7),(8);插入
为表创建索引:create index in_id on t1(id);
查看索引 show index from t1;
desc t2;查看表结构
出入一个一千万行的数据
insert into t2 values(1),(2),(3),(4);
insert into t2 select * from t2;
查看多少行
select count(*) from t2;
实时 监控命令:watch -nl ls -lh 1S刷新一次
alt+F2开启第二个终端
改变定界符:/d // 这样使用 ;就不是结束,不会开始执行
换回来 /d ;
free -m 内存使用
建立索引 create index idx_of_c3 on part_tab(c3)
默认索引文件名:ibdatal 在data目录下
mysql 表复制
mysql> create table t2 like t1;
复制表数据(表结构相同的情况下);
mysql>insert into t2 select * from t1;
我是看的这个视频http://pan.baidu.com/s/1lCASk
bitsCN.com