centos7安装mysql57

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29461259/article/details/64124807

1.rpm包式的安装操作

1.1 [root@localhost mysql]# rpm -Uvh mysql57-community-release-el7-8.noarch.rpm

warning: mysql57-community-release-el7-8.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-8  ################################# [100%]

1.2 [root@localhost mysql]# yum repolist all | grep mysql

mysql-connectors-community/x86_64 MySQL Connectors Community      enabled:    21
mysql-connectors-community-source MySQL Connectors Community - So disabled
mysql-tools-community/x86_64      MySQL Tools Community           enabled:    36
mysql-tools-community-source      MySQL Tools Community - Source  disabled
mysql-tools-preview/x86_64        MySQL Tools Preview             disabled
mysql-tools-preview-source        MySQL Tools Preview - Source    disabled
mysql55-community/x86_64          MySQL 5.5 Community Server      disabled
mysql55-community-source          MySQL 5.5 Community Server - So disabled
mysql56-community/x86_64          MySQL 5.6 Community Server      disabled
mysql56-community-source          MySQL 5.6 Community Server - So disabled
mysql57-community/x86_64          MySQL 5.7 Community Server      enabled:   110
mysql57-community-source          MySQL 5.7 Community Server - So disabled

1.3 [root@localhost mysql]# yum repolist enabled | grep mysql

mysql-connectors-community/x86_64       MySQL Connectors Community           21
mysql-tools-community/x86_64            MySQL Tools Community                36
mysql57-community/x86_64                MySQL 5.7 Community Server          110

1.4 [root@localhost mysql]# yum install mysql-community-server

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 ...
Resolving Dependencies
...
Dependencies Resolved
==============================================================
 Package          Arch   Version      Repository         Size
==============================================================
Installing:
 mysql-community-libs
                  x86_64 5.7.14-1.el7 mysql57-community 2.1 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs-compat
                  x86_64 5.7.14-1.el7 mysql57-community 2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server
                  x86_64 5.7.14-1.el7 mysql57-community 152 M
Installing for dependencies:
 mysql-community-client
                  x86_64 5.7.14-1.el7 mysql57-community  24 M
 mysql-community-common
                  x86_64 5.7.14-1.el7 mysql57-community 271 k

Transaction Summary
==============================================================
Install  3 Packages (+2 Dependent packages)

Total download size: 180 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.14-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.7.14-1.el7.x86_64.rpm is not installed
... 
(5/5): mysql-community-server-5.7.14-1.e | 152 MB   00:40     
--------------------------------------------------------------
Total                            3.5 MB/s | 180 MB  00:51     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 ...
Is this ok [y/N]: y
...
Warning: RPMDB altered outside of yum.
...
  Installing : mysql-community-ser [##############      ] 4/6^  Installing : mysql-community-server-5.7.14-1.el7.x86_   4/6 

2. 启动mysql并查看状态

2.1 [root@localhost mysql]# service mysqld start

Redirecting to /bin/systemctl start  mysqld.service

2.2 [root@localhost mysql]# service mysqld status

Redirecting to /bin/systemctl status  mysqld.service
...
 Main PID: 3936 (mysqld)
   CGroup: /system.slice/mysqld.service
           й╕йд3936 /usr/sbin/mysqld --daemonize --pid-file=/...

Aug 31 22:31:06 localhost.localdomain systemd[1]: Starting ...
..

3. 获取mysql默认的root密码并进行修改

3.1 [root@localhost mysql]# grep ‘temporary password’ /var/log/mysqld.log

2016-09-01T02:31:12.234701Z 1 [Note] A temporary password is generated for root@localhost: ?umjR+jp0qKG

3.2 [root@localhost mysql]# mysql -uroot -p

Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14
...

3.3 mysql>ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘PENG_fei_123456’;

Query OK, 0 rows affected (0.01 sec)

4. MySQL 5.7, 密码规则修改, 创建用户, 和用户授权操作

4.1 修改密码判断规则为基于密码的长度
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

4.2 创建用户
mysql> CREATE USER ‘test’@’%’ IDENTIFIED BY ‘12345678’;
Query OK, 0 rows affected (0.00 sec)

扫描二维码关注公众号,回复: 4063339 查看本文章

4.3 授权,授权所有的权限命令
mysql> GRANT ALL ON . TO ‘test’@’%’;
Query OK, 0 rows affected (0.00 sec)ti

5. centos7 firewall开放mysql端口永久生效

5.1 [root@localhost webrtc]# firewall-cmd –zone=public –add-port=3306/tcp –permanent
success
5.2 [root@localhost webrtc]# firewall-cmd –reload
success

猜你喜欢

转载自blog.csdn.net/qq_29461259/article/details/64124807