CentOS7 安装MySQL
#安装wget
yum -y install wget
#安装mysql-community-release-el7-5.noarch.rpm包
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
#安装MySQL
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
#安装服务
sudo yum install mysql-server
安装完成后重启。
#登录用户
mysql -u root
#修改密码
set password for root@localhost = password('123');
#添加远程连接的能力
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
#打开3306端口,实现远程连接服务
/sbin/iptables -I INPUT -p tcp --dport 3306-j ACCEPT
如果登录出现错误。
#把/var/lib/mysql得拥有者改为当前用户
chown root /var/lib/mysql
然后重启mysql服务
service mysqld start