1. 下載mysql的repo源mysql
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. 安裝mysql-community-release-el7-5.noarch.rpm包sql
$ 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. 安裝mysqlvim
$ sudo yum install mysql-server
根據步驟安裝就能夠了,不過安裝完成後,沒有密碼,須要重置密碼。socket
4. 重置密碼tcp
重置密碼前,首先要登陸rest
$ 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 openscanner:openscanner /var/lib/mysql 而後,重啓服務: $ service mysqld restart 接下來登陸重置密碼: $ mysql -u root mysql > use mysql; mysql > update user set password=password(‘123456‘) where user=‘root‘; mysql > exit;
5. 開放3306端口code
$ sudo vim /etc/sysconfig/iptables 添加如下內容: -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT 保存後重啓防火牆: $ sudo service iptables restart
這樣從其它客戶機也能夠鏈接上mysql服務了。server