1、删除系统自带的mysql
yum remove -y mysql-server mysql mysql-devel
//查询mysql的rpm包,删除
rpm -qa|grep mysql
rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
//查询mysqld的文件,删除
find / -name mysql
2、上传mysql安装包,进行安装
上传mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar
解压并安装rpm包
rpm -ivh mysql-community-common-5.7.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.13-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.13-1.el6.x86_64.rpm
3、初始化
mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/var/lib/mysql
3、修改root密码
mysqld_safe --user=root --skip-grant-tables --skip-networking &
mysql -u root mysql
UPDATE user SET authentication_string=PASSWORD('123456') where USER='root';
mysqladmin -uroot -p password '654321'
4、mysql授权
grant all on *.* to root@'localhost' identified by "123456";
5、查找
find $BAK_DIR -name "*.sql" -type f -mtime +30 -exec rm -rf {} \;
6、截取本机IP
IP=`ifconfig|grep Bcast|grep 192|awk '{print $2}'|sed 's/addr://g'`