查看是包含和安装mysql,有的话先删除
[root@server1 opt]# rpm -qa | grep -i mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@server1 opt]# yum -y remove mysql-libs*
下载mysql rpm安装包
MySQL-server-5.6.35-1.el6.x86_64.rpm
MySQL-client-5.6.35-1.el6.x86_64.rpm
MySQL-devel-5.6.35-1.el6.x86_64.rpm
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# rpm -ivh MySQL-client-5.6.35-1.el6.x86_64.rpm
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# rpm -ivh MySQL-devel-5.6.35-1.el6.x86_64.rpm
可能会出现依赖包不存在的情况 直接用yum安装即可
复制mysql配置文件
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
查看mysql初始密码
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# more /root/.mysql_secret
# The random password set for the root user at Wed Jan 18 14:32:33 2017 (local time): h7LDPJpSSXB9ErhR
启动mysql服务
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# service mysql start
用初始密码登陆mysql
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# mysql -uroot -ph7LDPJpSSXB9ErhR
修改密码为自己的密码 此处设为了root
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
设置开机启动
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# chkconfig mysql on
[root@server1 MySQL-5.6.35-1.el6.x86_64.rpm-bundle]# chkconfig --list mysq