#a. 查找已安裝的myslq 版本:
#rpm -qa | grep mysql (注意大小寫,如果mysql 不行就換MySQL)
在屏幕上將顯示已安裝的mysql包名如:mysql-5.0.22-2.1.0.1 ;
b. 將搜索出的包名卸載:
#rpm -e --nodeps mysql-5.0.22-2.1.0.1 (nodeps表示強(qiáng)制刪除)
c. 再次查找該包名,如果沒有結(jié)果輸出則表明已將該版本的mysql卸載了 ;
#2.安裝MySQL
#使用rpm包安裝
# rpm –ivh MySQL-server-enterprise-gpl-5.1.46sp1-1.rhel5.i386.rpm
# rpm –ivh MySQL-client-enterprise-gpl-5.1.46sp1-1.rhel5.i386.rpm
#安裝完成后在/usr/share/mysql目錄中會有一個mysql的啟動腳本mysql.server及示例配置文件等(如my-huge.cnf、my-large.cnf、my-medium.cnf)
cp my-medium.cnf /etc/my.cnf
#3.啟動和停止mysql
/etc/init.d/mysql start
/etc/init.d/mysql stop
/etc/init.d/mysql restart
#清除文件
rm -rf master.info relay-log.info *-relay-bin.index *-relay-bin.*
#查看復(fù)制狀態(tài)
show slave status;
show slave status\G;
#通過遠(yuǎn)程拷貝到從服務(wù)器上,通過這個拷貝的時候需要輸入node2的root密碼。
scp /root/db.tar root@192.168.1.2:/usr/local/mysql
#scp 總是顯示 Permission denied
先 scp 拷貝到遠(yuǎn)端 /tmp
#linux運(yùn)行時間
cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("系統(tǒng)已運(yùn)行:%d天%d時%d分%d秒",run_days,run_hour,run_minute,run_second)}'
top
#cp 命令 提示cp: 略過目錄 “/root/temp/sk”
解決方法:cp 后加-r
#備份數(shù)據(jù)庫
mysqldump -h192.168.102.88 -uroot -p123456 --opt -R DPOS > DPOS20101116.sql
mysqldump -h192.168.102.88 -uroot -p123456 --opt -R DPOS | gzip > DPOS20101116.sql.gz
#mysql ibdata1文件的縮小 收藏
mysql ibdata1文件的縮小(2009-12-22 15:29:46)
標(biāo)簽:it
mysql ibdata1存放數(shù)據(jù),索引等,是MYSQL的最主要的數(shù)據(jù)。
如果不把數(shù)據(jù)分開存放的話,這個文件的大小很容易就上了G,甚至10+G。對于某些應(yīng)用來說,并不是太合適。因此要把此文件縮小。
方法:數(shù)據(jù)文件單獨(dú)存放。
步驟:
1,備份數(shù)據(jù)庫
從命令行進(jìn)入MySQL Server 5.0\bin
備份全部數(shù)據(jù)庫,執(zhí)行命令mysqldump -q -uusername -pyourpassword --add-drop-table -all-databases > /all.sql
做完此步后,停止數(shù)據(jù)庫服務(wù)。
2,修改mysql配置文件
修改my.ini文件,增加下面配置
innodb_file_per_table
對每張表使用單獨(dú)的innoDB文件, 修改/etc/my.cnf文件
3,刪除原數(shù)據(jù)文件
刪除原來的ibdata1文件及日志文件ib_logfile*,刪除data目錄下的應(yīng)用數(shù)據(jù)庫文件夾(mysql文件夾不要刪)
4,還原數(shù)據(jù)庫
啟動數(shù)據(jù)庫服務(wù)
從命令行進(jìn)入MySQL Server 5.0\bin
還原全部數(shù)據(jù)庫,執(zhí)行命令mysql -uusername -pyourpassword < /all.sql
經(jīng)過以上幾步后,可以看到新的ibdata1文件就只有幾十M了,數(shù)據(jù)及索引都變成了針對單個表的小ibd文件了,它們在相應(yīng)數(shù)據(jù)庫的文件夾下面。
@查看備份日常mysql-bin
mysqlbinlog mysql-bin.000001
提示出錯mysqlbinlog: unknown variable 'default-character-set=utf8'
需要修改/etc/my.cnf中[client]部分,將default-character-set=utf8注釋掉,因?yàn)閙ysqlbinlog不支持這個參數(shù),他可以自動識別編碼
========================================================================
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,
or READS SQL DATA in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators
variable)
SET GLOBAL log_bin_trust_function_creators = 1;
grant all on *.* to LMSUSER@'%' identified by '123456';
flush privileges;
window下表名大寫 lower_case_table_names=2