【MySQL】Error “No package mysql-server available” while Installing mysql

【原文鏈接】https://www.techietown.info/2017/07/error-no-package-mysql-server-available-while-installing-mysql-server/

Mysql is a popular open source relational database management system (RDBMS). It is widely used and powering many popular websites/applications. Let us see how to install mysql-server on a Centos Server. On a fresh Centos Box, I tried to install “mysql-server” using yum . But following error was thrown

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

 

[root@eb2476e8763c /]# yum install mysql-server

Loaded plugins: fastestmirror, ovl

base | 3.6 kB 00:00:00

extras | 3.4 kB 00:00:00

http://ftp.iitm.ac.in/centos/7.3.1611/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#52 – “Empty reply from server”

Trying other mirror.

updates | 3.4 kB 00:00:00

(1/4): extras/7/x86_64/primary_db | 191 kB 00:00:01

(2/4): base/7/x86_64/group_gz | 155 kB 00:00:02

(3/4): updates/7/x86_64/primary_db | 7.8 MB 00:00:03

(4/4): base/7/x86_64/primary_db | 5.6 MB 00:00:04

Determining fastest mirrors

* base: centos.myfahim.com

* extras: centos.myfahim.com

* updates: centos.myfahim.com

No package mysql–server available.

Error: Nothing to do

 

 

Yum says its not able to find the package “mysql-server” in any of the available yum repositories. In order to fix this, we need to install the mysql yum repositories. Let us see how to do it.

 

How to enable mysql yum repository on Centos 6/7 ?

 

On Centos7, using

 

1

2

3

4

5

6

7

8

9

 

[root@eb2476e8763c /]# rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

Retrieving https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

warning: /var/tmp/rpm–tmp.7OOdD1: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ################################# [100%]

Updating / installing...

1:mysql57–community–release–el7–11 ################################# [100%]

[root@eb2476e8763c /]#

 

 

For Centos 6

 

1

2

3

4

5

6

7

8

 

[root@eb2476e8763c /]# rpm -ivh https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm

Retrieving https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm

warning: /var/tmp/rpm–tmp.TWlyW7: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ################################# [100%]

Updating / installing...

1:mysql57–community–release–el6–11 ################################# [100%]

 

 

Now we can install mysql-server using yum

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

 

[root@eb2476e8763c lib64]# yum install mysql-server

Loaded plugins: fastestmirror, ovl

base | 3.6 kB 00:00:00

extras | 3.4 kB 00:00:00

mysql–connectors–community | 2.5 kB 00:00:00

mysql–tools–community | 2.5 kB 00:00:00

mysql57–community | 2.5 kB 00:00:00

updates | 3.4 kB 00:00:00

mysql–connectors–community/x86_64/primary_db | 16 kB 00:00:01

Loading mirror speeds from cached hostfile

* base: centos.myfahim.com

* extras: centos.myfahim.com

* updates: centos.myfahim.com

Resolving Dependencies

—> Running transaction check

—–> Package mysql–community–server.x86_64 0:5.7.19–1.el7 will be installed

 

Installed:

mysql–community–server.x86_64 0:5.7.19–1.el7

 

Verify the installed packages using “rpm” command

 

[root@eb2476e8763c lib64]# rpm -qa |grep mysql

mysql–community–libs–5.7.19–1.el7.x86_64

mysql57–community–release–el7–11.noarch

mysql–community–common–5.7.19–1.el7.x86_64

mysql–community–client–5.7.19–1.el7.x86_64

mysql–community–server–5.7.19–1.el7.x86_64

[root@eb2476e8763c lib64]#

 

 

As you can see, mysql server and client packages are installed.

 

To start mysql service,

 

On centos7

 

1

systemctl start mysql

 

On Centos6

 

1

service mysqld start

 

Verify “mysql-server” is listening on port 3306 , using

 

1

2

# netstat -nap |grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9782/mysqld

 

Now you can connect to mysql-server using “mysql” client

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

[root@localhost ~]# mysql

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

Your MySQL connection id is 4

Server version: 5.7.18–log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2017, 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>

 

Now we can run the mysql queries on mysql prompt. Please let us know incase you find any issue.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章