Centos 安裝Mysql記錄

weixin_34321977發表於2017-12-07

Linux安裝Mysql

下載mysql的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

安裝mysql-community-release-el7-5.noarch.rpm包

sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

安裝mysql

sudo yum install mysql-server

ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket

sudo chown -R openscanner:openscanner /var/lib/mysql

然後,重啟服務

service mysqld restart

接下來登入重置密碼

mysql -u root
mysql > use mysql;
mysql > update user set password=password('pencilso') where user='root';
mysql > exit;

開放3306埠

 sudo vim /etc/sysconfig/iptables

新增以下內容

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

儲存後重啟防火牆

 sudo service iptables restart

相關文章