centosインストールmysql 5.6

9064 ワード

一、まずmysql 5をダウンロードする.6必要なインストールパッケージは、rpm方式でインストールされているので、ダウンロードして以下のインストールパッケージをダウンロードします.
MySQL-client-5.6.15-1.el6.x86_64.rpm
MySQL-devel-5.6.15-1.el6.x86_64.rpm
MySQL-server-5.6.15-1.el6.x86_64.rpm
システムがネットワークに接続できる場合は、以下の方法でダウンロードすることができ、インターネットに接続できない場合は、以下のアドレスに基づいて事前にダウンロードすることができます.
wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-client-5.6.15-1.el6.x86_64.rpm

  
wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-devel-5.6.15-1.el6.x86_64.rpm

 
wget http://cdn.mysql.com/archives/mysql-5.6/MySQL-server-5.6.15-1.el6.x86_64.rpm

 
二、mysqlのインストール
2.1システムにmysqlがインストールされているかどうかを確認する
システムにmysqlがインストールされているかどうかを確認するには、次のコマンドを実行します.
rpm -qa|grep mysql

システムの実行結果は次のとおりです.
[root@localhost tmp]# rpm -qa|grep mysql
mysql-libs-5.1.61-4.el6.x86_64

以上の結果はmysql-libsがインストールされ、バージョンが5.1.61であることを示しています.この場合、パッケージを削除する必要があります.そうしないと、インストール時に競合が報告されます.以下に示します.
MySQL-server-5.6.15-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

mysql対応パッケージを削除するには、次の手順に従います.
yum -y remove mysql*

2.2 mysqlのインストール
次のコマンドを順に実行してインストールします.
rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm

 
rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm

 
rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm

実行結果は次のとおりです.
[root@localhost tmp]# rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ^A########################################### [100%]
2016-02-04 18:50:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-04 18:50:40 6295 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-04 18:50:40 6295 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-04 18:50:40 6295 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-04 18:50:40 6295 [Note] InnoDB: Using Linux native AIO
2016-02-04 18:50:40 6295 [Note] InnoDB: Using CPU crc32 instructions
2016-02-04 18:50:40 6295 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-04 18:50:41 6295 [Note] InnoDB: Completed initialization of buffer pool
2016-02-04 18:50:41 6295 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-02-04 18:50:41 6295 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-02-04 18:50:41 6295 [Note] InnoDB: Database physically writes the file full: wait...
2016-02-04 18:50:41 6295 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-02-04 18:50:47 6295 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-02-04 18:50:53 6295 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-02-04 18:50:53 6295 [Warning] InnoDB: New log files created, LSN=45781
2016-02-04 18:50:53 6295 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-02-04 18:50:53 6295 [Note] InnoDB: Doublewrite buffer created
2016-02-04 18:50:53 6295 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-04 18:50:53 6295 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-02-04 18:50:53 6295 [Note] InnoDB: Foreign key constraint system tables created
2016-02-04 18:50:53 6295 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-02-04 18:50:53 6295 [Note] InnoDB: Tablespace and datafile system tables created.
2016-02-04 18:50:53 6295 [Note] InnoDB: Waiting for purge to start
2016-02-04 18:50:53 6295 [Note] InnoDB: 5.6.15 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2016-02-04 18:50:54 6295 [Note] Binlog end
2016-02-04 18:50:54 6295 [Note] InnoDB: FTS optimize thread exiting.
2016-02-04 18:50:54 6295 [Note] InnoDB: Starting shutdown...
2016-02-04 18:50:55 6295 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2016-02-04 18:50:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-04 18:50:55 6333 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-04 18:50:55 6333 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-04 18:50:55 6333 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-04 18:50:55 6333 [Note] InnoDB: Using Linux native AIO
2016-02-04 18:50:55 6333 [Note] InnoDB: Using CPU crc32 instructions
2016-02-04 18:50:55 6333 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-04 18:50:55 6333 [Note] InnoDB: Completed initialization of buffer pool
2016-02-04 18:50:55 6333 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-04 18:50:55 6333 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-04 18:50:55 6333 [Note] InnoDB: Waiting for purge to start
2016-02-04 18:50:55 6333 [Note] InnoDB: 5.6.15 started; log sequence number 1625977
2016-02-04 18:50:55 6333 [Note] Binlog end
2016-02-04 18:50:55 6333 [Note] InnoDB: FTS optimize thread exiting.
2016-02-04 18:50:55 6333 [Note] InnoDB: Starting shutdown...
2016-02-04 18:50:57 6333 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

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

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

[root@localhost tmp]# rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@localhost tmp]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@localhost tmp]# 

実行結果は上記のようにmysqlのインストールに成功したことを示しています.
三、mysqlの構成
mysqlsqlプロファイルを/etc/myにコピーします.cnf
 
cp /usr/share/mysql/my-default.cnf /etc/my.cnf

mysqlデータベースの初期化
/usr/bin/mysql_install_db

mysqlの起動
[root@localhost tmp]# service mysql start
Starting MySQL................... SUCCESS! 

mysqlランダムパスワードの表示
[root@localhost tmp]# cat /root/.mysql_secret
# The random password set for the root user at Thu Feb  4 18:50:54 2016 (local time): 8CSQIhhd

mysqlへのログイン
コマンドの実行
mysql -uroot -p

表示されるパスワードを入力:
[root@localhost tmp]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.15

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

 
mysqlパスワードを変更するには:
 
mysql> set password for 'root'@'localhost' =password('123456');
Query OK, 0 rows affected (0.02 sec)

権限のリフレッシュ
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 
 
 
これでcentosにmysql 5のインストールが完了します.6