CentOS7 安装mysql 更换yum源 [root@#localhost ~]# cd /etc/yum.repos.d/ [root@#localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo [root@#localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup [root@#localhost yum.repos.d]# mv CentOS6-Base-163.repo CentOS-Base.repo [root@#localhost yum.repos.d]# yum makecache 获取mysql rpm信息 [root@#localhost yum.repos.d]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [root@#localhost yum.repos.d]# rpm --rebuilddb yum 安装mysql [root@#localhost yum.repos.d]# yum install mysql-server 配置开机启动服务 [root@#localhost yum.repos.d]# chkconfig mysqld on 启动mysql服务,检查是否正常启动 [root@#localhost yum.repos.d]# systemctl start mysqld.service 初始化数据库信息 [root@#localhost yum.repos.d]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & [root@#localhost yum.repos.d]# mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('root') where USER='root'; mysql> flush privileges;