天天看点

CentOS 6.5通过yum安装mysql 5.5、5.6、5.7版本

1、安装mysql的yum源,这个源包括5.5、5.6、5.7版本:

1

2

3

4

5

<code>[root@agile ~]</code><code># rpm -ivh http://repo.mysql.com/mysql-community-release-el6.rpm</code>

<code>Retrieving http:</code><code>//repo</code><code>.mysql.com</code><code>/mysql-community-release-el6</code><code>.rpm</code>

<code>warning: </code><code>/var/tmp/rpm-tmp</code><code>.C87LHo: Header V3 DSA</code><code>/SHA1</code> <code>Signature, key ID 5072e1f5: NOKEY</code>

<code>Preparing...                </code><code>########################################### [100%]</code>

<code>   </code><code>1:mysql-community-release</code><code>########################################### [100%]</code>

2、打开mysql的yum源文件,如果要安装mysql哪个版本,选择后把里面的enable设置为1。

备注:或者用yum-config-manager命令方式开启或关闭。

yum-config-manager --disable mysql55-community

yum-config-manager --enable mysql56-community

yum-config-manager --disable mysql57-community

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<code>[root@agile ~]</code><code>#vim /etc/yum.repos.d/mysql-community.repo</code>

<code># Enable to use MySQL 5.5</code>

<code>[mysql55-community]</code>

<code>name=MySQL 5.5 Community Server</code>

<code>baseurl=http:</code><code>//repo</code><code>.mysql.com</code><code>/yum/mysql-5</code><code>.5-community</code><code>/el/6/</code><code>$basearch/</code>

<code>enabled=0</code>

<code>gpgcheck=1</code>

<code>gpgkey=</code><code>file</code><code>:</code><code>///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql</code>

<code># Enable to use MySQL 5.6</code>

<code>[mysql56-community]</code>

<code>name=MySQL 5.6 Community Server</code>

<code>baseurl=http:</code><code>//repo</code><code>.mysql.com</code><code>/yum/mysql-5</code><code>.6-community</code><code>/el/6/</code><code>$basearch/</code>

<code>enabled=1</code>

<code>[mysql57-community]</code>

<code>name=MySQL 5.7 Community Server</code>

<code>baseurl=http:</code><code>//repo</code><code>.mysql.com</code><code>/yum/mysql-5</code><code>.7-community</code><code>/el/6/</code><code>$basearch/</code>

3、yum安装mysql组件。

<code>[root@agile ~]</code><code>#yum install mysql-community-client mysql-community-devel mysql-community-server php-mysql</code>

<code>正在安装:</code>

<code> </code><code>mysql-community-client                    x86_64               5.6.38-2.el6                 mysql56-community                18 M</code>

<code> </code><code>mysql-community-devel                     x86_64               5.6.38-2.el6                 mysql56-community               3.3 M</code>

<code> </code><code>mysql-community-libs                      x86_64               5.6.38-2.el6                 mysql56-community               1.9 M</code>

<code>     </code><code>replacing  mysql-libs.x86_64 5.1.73-8.el6_8</code>

<code> </code><code>mysql-community-libs-compat               x86_64               5.6.38-2.el6                 mysql56-community               1.6 M</code>

<code> </code><code>mysql-community-server                    x86_64               5.6.38-2.el6                 mysql56-community                55 M</code>

<code> </code><code>php-mysql                                 x86_64               5.3.3-49.el6                 base                             86 k</code>

<code>为依赖而安装:</code>

<code> </code><code>mysql-community-common                    x86_64               5.6.38-2.el6                 mysql56-community               308 k</code>

<code> </code><code>numactl                                   x86_64               2.0.9-2.el6                  base                             74 k</code>

<code> </code><code>php-common                                x86_64               5.3.3-49.el6                 base                            530 k</code>

<code> </code><code>php-pdo                                   x86_64               5.3.3-49.el6                 base                             80 k</code>

4、启动mysql命令,并设置开机自启动。

<code>[root@agile ~]</code><code>#service mysqld start</code>

<code>[root@agile ~]</code><code>#chkconfig mysqld on</code>

5、mysql设置root密码。

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

<code>[root@agile ~]</code><code>#mysql_secure_installation</code>

<code>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL</code>

<code>      </code><code>SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!</code>

<code>In order to log into MySQL to secure it, we'll need the current</code>

<code>password </code><code>for</code> <code>the root user.  If you've just installed MySQL, and</code>

<code>you haven't </code><code>set</code> <code>the root password yet, the password will be blank,</code>

<code>so you should just press enter here.</code>

<code>Enter current password </code><code>for</code> <code>root (enter </code><code>for</code> <code>none): </code>

<code>OK, successfully used password, moving on...</code>

<code>Setting the root password ensures that nobody can log into the MySQL</code>

<code>root user without the proper authorisation.</code>

<code>Set root password? [Y</code><code>/n</code><code>] y</code>

<code>New password: </code>

<code>Re-enter new password: </code>

<code>Password updated successfully!</code>

<code>Reloading privilege tables..</code>

<code> </code><code>... Success!</code>

<code>By default, a MySQL installation has an anonymous user, allowing anyone</code>

<code>to log into MySQL without having to have a user account created </code><code>for</code>

<code>them.  This is intended only </code><code>for</code> <code>testing, and to </code><code>make</code> <code>the installation</code>

<code>go a bit smoother.  You should remove them before moving into a</code>

<code>production environment.</code>

<code>Remove anonymous </code><code>users</code><code>? [Y</code><code>/n</code><code>] y</code>

<code>Normally, root should only be allowed to connect from </code><code>'localhost'</code><code>.  This</code>

<code>ensures that someone cannot guess at the root password from the network.</code>

<code>Disallow root login remotely? [Y</code><code>/n</code><code>] y</code>

<code>By default, MySQL comes with a database named </code><code>'test'</code> <code>that anyone can</code>

<code>access.  This is also intended only </code><code>for</code> <code>testing, and should be removed</code>

<code>before moving into a production environment.</code>

<code>Remove </code><code>test</code> <code>database and access to it? [Y</code><code>/n</code><code>] y</code>

<code> </code><code>- Dropping </code><code>test</code> <code>database...</code>

<code>ERROR 1008 (HY000) at line 1: Can</code><code>'t drop database '</code><code>test</code><code>'; database doesn'</code><code>t exist</code>

<code> </code><code>... Failed!  Not critical, keep moving...</code>

<code> </code><code>- Removing privileges on </code><code>test</code> <code>database...</code>

<code>Reloading the privilege tables will ensure that all changes made so far</code>

<code>will take effect immediately.</code>

<code>Reload privilege tables now? [Y</code><code>/n</code><code>] y</code>

<code>All </code><code>done</code><code>!  If you've completed all of the above steps, your MySQL</code>

<code>installation should now be secure.</code>

<code>Thanks </code><code>for</code> <code>using MySQL!</code>

<code>Cleaning up...</code>

<code></code>

本文转自 sailikung 51CTO博客,原文链接:http://blog.51cto.com/net881004/2054052,如需转载请自行联系原作者