【服务器实战搭建】centos7下使用yum安装mysql
2016-11-02 21:26
791 查看
CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。1. 下载mysql的repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm2. 安装mysql-community-release-el7-5.noarch.rpm包
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。3. 安装mysql
$ sudo yum install mysql-server根据步骤安装就可以了,不过安装完成后,没有密码,需要重置密码。4. 重置密码重置密码前,首先要登录
$ mysql -u root登录时有可能报这样的错:ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
$ sudo chown -R mysql:mysql /var/lib/mysql然后,重启服务:
$ service mysqld restart接下来登录重置密码:
$ mysql -u root
mysql > use mysql; mysql > update user set password=password('root') where user='root'; mysql > exit;5. 开放3306端口
$ sudo vim /etc/sysconfig/iptables添加以下内容:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT保存后重启防火墙:
$ sudo service iptables restart这样从其它客户机也可以连接上mysql服务了。
相关文章推荐
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- CentOS 5.5服务器使用yum安装配置Apache、PHP和Mysql
- 实战mysql集群搭建(一)--centos7下二进制安装mysql-5.6
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- 转载:centos7下使用yum安装mysql
- 在CentOS 7下使用yum配置MySQL源并安装MySQL
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- CentOS 7下快速安装Gitlab,搭建个人或者公司内部使用的Git服务器
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql