1. 程式人生 > >CentOS7.2安裝MySQL 5.7.10

CentOS7.2安裝MySQL 5.7.10

1.下載MySQL源

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm


2.安裝MySQL源

sudo rpm -ivh mysql57-community-release-el7-7.noarch.rpm


3.安裝mysql-community-server

sudo yum install mysql-community-server -y


4.重啟mysql
systemctl restart mysqld

注:自動啟動服務用 systemctl enable mysql


5.檢視臨時密碼
grep 'A temporary password' /var/log/mysqld.log

2015-12-24T08:04:50.296020Z 1 [Note] A temporary password is generated for [email protected]: I(eKs9PyklP_


6.用臨時密碼登入mysql並修改root密碼,新增使用者,開啟遠端訪問
>mysql -uroot -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15
Server version: 5.7.10 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified by ‘Abc123///';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user hadoop identified by ‘Abc123///‘
Query OK, 0 rows affected (0.00 sec)
mysql>grant all privileges on *.* to 'root'@'%' identified by ‘Abc123///' with grant option; 

Query OK, 0 rows affected, 1 warning (0.00 sec)


7.開啟防火牆並重啟防火牆,確認埠
sudo  firewall-cmd --permanent --add-service mysql
systemctl restart firewalld.service
iptables -L -n|grep 3306