【大数据】CentOS6.5安装mysql5.6(靠谱!)

 

一、吐槽

       我明明是跟着老师写的书上一步一步来的,到最后出现了一堆错误,然后从网上找教程,网上那些人不知道咋想的,啥也往上贴,随便一篇,除了自己能看懂没几个人能看懂的文章就贴到网上了。

       结果就是,在原先错误的基础上又一大堆错。

       于是,我把我所有操作过的文件全部删除了(一天之内操作过什么文件我基本上是能记住的,我记忆力超群,哈哈。)

       当然,我敢删是因为我觉得找到了一篇靠谱的文章,来自51CTO的Willson_luo《3分钟,YUM升级MYSQL,5.1到5.6》,链接如下:

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

       这位肯定是一位大神了,因为他通篇文章没说几句话,就是默默的贴出代码,所以我斗胆借着他的成果,加上我的一些废话,发表于此,侵删。

二、安装

 

注:以下红色字体都是终端命令,黑色正常字体为命令执行过程及结果

1、首先第一步,看一下有没有安装mysql ( V是大写的 )

[root@master /]# mysql -V

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

 

2、我这里是安装好了的,而且是5.6.42版本,如果你不是这个版本,想要使用这个版本,那么就先把你电脑上的mysql给卸载掉。

[root@master 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)

[root@master /]#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

[root@master /]# 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是大写的)

 

[root@master /]# mysql -V

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

5、开启mysql服务

[root@master /]# /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数据库

[root@master /]# 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服务,老师书上给的是下面这个命令,我执行了一下是失败的,你可以尝试一下

[root@master /]# service mysql restart

mysql: unrecognized service

10、下面这个才是真正的重启mysql服务的命令(比上面多个d)

[root@master /]# service mysqld restart

Stopping mysqld:                                           [  OK  ]

Starting mysqld:                                           [  OK  ]

11、如果出现了两个OK,之后就是登陆mysql客户端了

 [root@master /]# 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之旅~~~

 

 

.


看完如果觉得不错,留个赞再走。


.

猜你喜欢

转载自blog.csdn.net/midnight_time/article/details/83718173