1. 程式人生 > >【大資料】CentOS6.5安裝mysql5.6(靠譜!)

【大資料】CentOS6.5安裝mysql5.6(靠譜!)

 

一、吐槽

       我明明是跟著老師寫的書上一步一步來的,到最後出現了一堆錯誤,然後從網上找教程,網上那些人不知道咋想的,啥也往上貼,隨便一篇,除了自己能看懂沒幾個人能看懂的文章就貼到網上了。

       結果就是,在原先錯誤的基礎上又一大堆錯。

       於是,我把我所有操作過的檔案全部刪除了(一天之內操作過什麼檔案我基本上是能記住的,我記憶力超群,哈哈。)

       當然,我敢刪是因為我覺得找到了一篇靠譜的文章,來自51CTO的

Willson_luo《3分鐘,YUM升級MYSQL,5.1到5.6》,連結如下:

http://blog.51cto.com/10264683/2057472

       這位肯定是一位大神了,因為他通篇文章沒說幾句話,就是默默的貼出程式碼,所以我斗膽藉著他的成果,加上我的一些廢話,發表於此,侵刪。

二、安裝

 

注:以下紅色字型都是終端命令,黑色正常字型為命令執行過程及結果

1、首先第一步,看一下有沒有安裝mysql ( V是大寫的 )

[[email protected] /]# mysql -V

mysql  Ver 14.14 Distrib 5.6.42, for Linux (x86_64) using  EditLine wrapper

 

2、我這裡是安裝好了的,而且是5.6.42版本,如果你不是這個版本,想要使用這個版本,那麼就先把你電腦上的mysql給解除安裝掉。

[[email protected] etc]# yum -y remove mysql

Loaded plugins: fastestmirror, refresh-packagekit, security

Setting up Remove Process

Resolving Dependencies

--> Running transaction check

---> Package mysql-community-client.x86_64 0:5.6.42-2.el6 will be erased

--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.42-2.el6.x86_64

--> Running transaction check

---> Package mysql-community-server.x86_64 0:5.6.42-2.el6 will be erased

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================================

 Package                  Arch     Version           Repository            Size

================================================================================

Removing:

 mysql-community-client   x86_64   5.6.42-2.el6      @mysql56-community    83 M

Removing for dependencies:

 mysql-community-server   x86_64   5.6.42-2.el6      @mysql56-community   242 M

 

Transaction Summary

================================================================================

Remove        2 Package(s)

 

Installed size: 325 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Erasing    : mysql-community-server-5.6.42-2.el6.x86_64                   1/2

warning:    erase unlink of /etc/my.cnf failed: No such file or directory

  Erasing    : mysql-community-client-5.6.42-2.el6.x86_64                   2/2

  Verifying  : mysql-community-client-5.6.42-2.el6.x86_64                   1/2

  Verifying  : mysql-community-server-5.6.42-2.el6.x86_64                   2/2

 

Removed:

  mysql-community-client.x86_64 0:5.6.42-2.el6                                  

 

Dependency Removed:

  mysql-community-server.x86_64 0:5.6.42-2.el6                                 

 

Complete!

 

3、看到上面的Complete!就代表解除安裝完成了。

接下來就要安裝MySQL5.6了(複製貼上下面的命令就行,不過注意,中間有讓確認是否安裝,需要輸入一次或者兩次小寫的y)

[[email protected] /]#rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

Retrieving http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

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

       package mysql-community-release-el6-5.noarch is already installed

[[email protected] /]# yum install mysql-community-server

Loaded plugins: fastestmirror, refresh-packagekit, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * extras: mirrors.huaweicloud.com

 * updates: mirror.bit.edu.cn

Resolving Dependencies

--> Running transaction check

---> Package mysql-community-server.x86_64 0:5.6.42-2.el6 will be installed

--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.42-2.el6.x86_64

--> Running transaction check

---> Package mysql-community-client.x86_64 0:5.6.42-2.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================================

 Package                   Arch      Version         Repository            Size

================================================================================

Installing:

 mysql-community-server    x86_64    5.6.42-2.el6    mysql56-community     55 M

Installing for dependencies:

 mysql-community-client    x86_64    5.6.42-2.el6    mysql56-community     18 M

 

Transaction Summary

================================================================================

Install       2 Package(s)

 

Total download size: 73 M

Installed size: 325 M

Is this ok [y/N]: y     (←←←這裡有個小寫的y需要輸入)

Downloading Packages:

(1/2): mysql-community-client-5.6.42-2.el6.x86_64.rpm    |  18 MB     00:12    

(2/2): mysql-community-server-5.6.42-2.el6.x86_64.rpm    |  55 MB     00:38    

--------------------------------------------------------------------------------

Total                                           1.0 MB/s |  73 MB     01:13    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : mysql-community-client-5.6.42-2.el6.x86_64                   1/2

  Installing : mysql-community-server-5.6.42-2.el6.x86_64                   2/2

  Verifying  : mysql-community-client-5.6.42-2.el6.x86_64                   1/2

  Verifying  : mysql-community-server-5.6.42-2.el6.x86_64                   2/2

 

Installed:

  mysql-community-server.x86_64 0:5.6.42-2.el6                                 

 

Dependency Installed:

  mysql-community-client.x86_64 0:5.6.42-2.el6                                 

 

Complete!

4、看到上面的Complete!就代表安裝完成了。

接下來看一下自己安裝的版本吧。( V是大寫的)

 

[[email protected] /]# mysql -V

mysql  Ver 14.14 Distrib 5.6.42, for Linux (x86_64) using  EditLine wrapper

5、開啟mysql服務

[[email protected] /]# /etc/init.d/mysqld start  ( 也可以使用 service mysqld start )

Initializing MySQL database:  2018-11-04 01:24:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-04 01:24:09 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2018-11-04 01:24:09 0 [Note] /usr/sbin/mysqld (mysqld 5.6.42) starting as process 3781 ...

2018-11-04 01:24:09 3781 [Note] InnoDB: Using atomics to ref count buffer pool pages

2018-11-04 01:24:09 3781 [Note] InnoDB: The InnoDB memory heap is disabled

2018-11-04 01:24:09 3781 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2018-11-04 01:24:09 3781 [Note] InnoDB: Memory barrier is not used

2018-11-04 01:24:09 3781 [Note] InnoDB: Compressed tables use zlib 1.2.11

2018-11-04 01:24:09 3781 [Note] InnoDB: Using Linux native AIO

2018-11-04 01:24:09 3781 [Note] InnoDB: Using CPU crc32 instructions

2018-11-04 01:24:09 3781 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2018-11-04 01:24:09 3781 [Note] InnoDB: Completed initialization of buffer pool

2018-11-04 01:24:09 3781 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2018-11-04 01:24:09 3781 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2018-11-04 01:24:09 3781 [Note] InnoDB: Database physically writes the file full: wait...

2018-11-04 01:24:09 3781 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2018-11-04 01:24:10 3781 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2018-11-04 01:24:10 3781 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2018-11-04 01:24:10 3781 [Warning] InnoDB: New log files created, LSN=45781

2018-11-04 01:24:10 3781 [Note] InnoDB: Doublewrite buffer not found: creating new

2018-11-04 01:24:10 3781 [Note] InnoDB: Doublewrite buffer created

2018-11-04 01:24:10 3781 [Note] InnoDB: 128 rollback segment(s) are active.

2018-11-04 01:24:10 3781 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-11-04 01:24:10 3781 [Note] InnoDB: Foreign key constraint system tables created

2018-11-04 01:24:10 3781 [Note] InnoDB: Creating tablespace and datafile system tables.

2018-11-04 01:24:10 3781 [Note] InnoDB: Tablespace and datafile system tables created.

2018-11-04 01:24:10 3781 [Note] InnoDB: Waiting for purge to start

2018-11-04 01:24:11 3781 [Note] InnoDB: 5.6.42 started; log sequence number 0

2018-11-04 01:24:11 3781 [Note] Binlog end

2018-11-04 01:24:11 3781 [Note] InnoDB: FTS optimize thread exiting.

2018-11-04 01:24:11 3781 [Note] InnoDB: Starting shutdown...

2018-11-04 01:24:13 3781 [Note] InnoDB: Shutdown completed; log sequence number 1625977

 

 

2018-11-04 01:24:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-04 01:24:13 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.

2018-11-04 01:24:13 0 [Note] /usr/sbin/mysqld (mysqld 5.6.42) starting as process 3803 ...

2018-11-04 01:24:13 3803 [Note] InnoDB: Using atomics to ref count buffer pool pages

2018-11-04 01:24:13 3803 [Note] InnoDB: The InnoDB memory heap is disabled

2018-11-04 01:24:13 3803 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2018-11-04 01:24:13 3803 [Note] InnoDB: Memory barrier is not used

2018-11-04 01:24:13 3803 [Note] InnoDB: Compressed tables use zlib 1.2.11

2018-11-04 01:24:13 3803 [Note] InnoDB: Using Linux native AIO

2018-11-04 01:24:13 3803 [Note] InnoDB: Using CPU crc32 instructions

2018-11-04 01:24:13 3803 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2018-11-04 01:24:13 3803 [Note] InnoDB: Completed initialization of buffer pool

2018-11-04 01:24:13 3803 [Note] InnoDB: Highest supported file format is Barracuda.

2018-11-04 01:24:13 3803 [Note] InnoDB: 128 rollback segment(s) are active.

2018-11-04 01:24:13 3803 [Note] InnoDB: Waiting for purge to start

2018-11-04 01:24:13 3803 [Note] InnoDB: 5.6.42 started; log sequence number 1625977

2018-11-04 01:24:13 3803 [Note] Binlog end

2018-11-04 01:24:13 3803 [Note] InnoDB: FTS optimize thread exiting.

2018-11-04 01:24:13 3803 [Note] InnoDB: Starting shutdown...

2018-11-04 01:24:14 3803 [Note] InnoDB: Shutdown completed; log sequence number 1625987

 

 

 

 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

 

  /usr/bin/mysqladmin -u root password 'new-password'

  /usr/bin/mysqladmin -u root -h master password 'new-password'

 

Alternatively you can run:

 

  /usr/bin/mysql_secure_installation

 

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

 

See the manual for more instructions.

 

Please report any problems at http://bugs.mysql.com/

 

The latest information about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL by buying support/licenses at http://shop.mysql.com

 

Note: new default config file not created.

Please make sure your config file is current

 

WARNING: Default config file /etc/my.cnf exists on the system

This file will be read by default by the MySQL server

If you do not want to use this, either remove it, or use the

--defaults-file argument to mysqld_safe when starting the server

 

                                                           [  OK  ]

Starting mysqld:                                           [  OK  ]

6、如果能看到兩個OK,就代表mysql服務啟動成功了,接下來嘗試進入mysql資料庫

[[email protected] /]# mysql

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

Your MySQL connection id is 2

Server version: 5.6.42 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2018, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

7、如果能看到databases的資訊,就代表mysql資料庫是可以使用了。只不過現在需要修改一下密碼。

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

8、把root使用者的密碼改為jmxx

mysql> update user set password=PASSWORD("jmxx")where User='root';

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4  Changed: 4  Warnings: 0

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> quit;

Bye

9、重啟mysql服務,老師書上給的是下面這個命令,我執行了一下是失敗的,你可以嘗試一下

[[email protected] /]# service mysql restart

mysql: unrecognized service

10、下面這個才是真正的重啟mysql服務的命令(比上面多個d)

[[email protected] /]# service mysqld restart

Stopping mysqld:                                           [  OK  ]

Starting mysqld:                                           [  OK  ]

11、如果出現了兩個OK,之後就是登陸mysql客戶端了

 [[email protected] /]# mysql -uroot -p

Enter password: (這裡輸入jmxx,密碼是不顯示的)

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

Your MySQL connection id is 2

Server version: 5.6.42 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2018, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

 

12恭喜!你已經開啟了屬於你的mysql之旅~~~

 

 

.


看完如果覺得不錯,留個贊再走。


.