mysql RPM包安装

1.------先卸载

rpm -qa | grep mysql
mysql-libs-5.1.61-4.el6.x86_64rpm -e 
mysql-libs-5.1.61-4.el6.x86_64 --nodeps

2.-----再安装----
注意,因为包之间有彼此依赖,所以安装有顺序要求,

rpm -ivh MySQL-server-5.6.31-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.31-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-client-5.6.31-1.linux_glibc2.5.x86_64.rpm

3. 初始化数据库,启动和配置

安装完成,需要初始化数据库,
mysql_install_db
复制配置文件,
cp /usr/share/mysql/my-default.cnf /etc/my.cnf启动MySQL服务,
service mysql start
设置开机启动,
chkconfig mysql on
检索设置生效,
chkconfig --list | grep mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

4. 重置密码

上面初始化操作,记录了root账户的临时密码,存储于文件/root/.mysql_secret中,

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
 
/root/.mysql_secret文件,
# The random password set for the root user at Mon Aug 28 09:40:09 2017 (local time): pcqEmPanlf3emxWW