MYSQL相关完整笔记

useradd mysql -s /sbin/nologin

cat/etc/passwd | grep mysql
cat /etc/group | grep mysql

源目录

cd /usr/src/mysq

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3306

./cmake.sh gmake make install
mkdir /var/lib/mysql
chown mysql.mysql
ll

ls
:(configure.cmake)

cd /usr/local/mysql
cd support-files/
mysql.server
cp mysql.server /etc/init.d/mysql
cp my-default.cnf /etc/my.cnf
vi my.cnf
basedir=/usr/local/mysql
datadir=/var/lib/mysql
port= 3306
socket=/temp/mysqld.sock

cd /usr/local/mysql/scripts/
./mysql_install_db --help

./mysql_install_db --basedir=/usr/local/msql/ --datadir=/var/lib/mysql --no-defaults --usre=mysql
cd /var/lib/mysql
service mysql start
ps -ef |grep mysql

cd /usr/local/mysql/
cd bin/
./mysql
cd
vi .bash_profile
PATH=$PATH/bin:/usr/local/mysql/bin
source ~/.bash_profile

加log恢复功能

vi /etc/my.cnf

要想通过日志恢复数据库,在你的my.cnf文件里应该有如下的定义,log-bin=mysql-bin,这个是必须的.binlog-do-db=db_test,这个是指定哪些数据库需要日志,如果有多个数据库就每行一个,如果不指定的话默认就是所有数据库.
[mysqld]
log-bin=mysql-bin
binlog-do-db=db_test
binlog-do-db=db_test2

expire_logs_day=3设置日志的过期天数,过了指定的天数,会自动删除

--------------------------------------

reset master(清空所有的二进制日志文件)
purge master logs to 'bintest.000006';(删除bintest.000006之前的二进制日志文件)

purge master logs before '2007-08-10 04:07:00'(删除该日期之前的日志)

SHOW BINLOG EVENTS G

1.还原全部数据库:

(1) mysql命令行:mysql>source f:\all.sql

(2) 系统命令行: mysql -uroot -p123456 <f:\all.sql

上一篇:XtraGrid的若干种用法 z


下一篇:python-time 模块