Help us understand the problem. What is going on with this article?

CentOS6.3でMySQL5.6.14をソースからインストール

More than 5 years have passed since last update.

CentOS6.3でMySQL5.6.14をソースからインストール

環境

# uname -a
Linux ttakahashi 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/redhat-release 
CentOS release 6.3 (Final)

前提

  • CentOS6.3
  • Apache2.4.6をインストール済み
  • PHP5.5をインストール済み

MySQLのインストール

1.MySQLソースファイルのダウンロード

# cd /usr/local/src/
# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz/from/http://cdn.mysql.com/
# tar xvfz mysql-5.6.14.tar.gz
# cd /usr/local/src/mysql-5.6.14
→ configureがない・・・cmakeが必要らしい

2.cmakeソースファイルのダウンロード&インストール

# cd /usr/local/src/
# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz
# tar xvfz cmake-2.8.12.tar.gz
#  cd cmake-2.8.12
# ./configure
# make
# make install

3.MySQL インストール

# cd /usr/local/src/mysql-5.6.14
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
Curses library not found.  Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
→ エラー発生、ncurses-develが必要

ncurses-develインストール

# cd /usr/local/src/
# wget ftp://rpmfind.net/linux/centos/6.4/os/x86_64/Packages/ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
# rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

再度インストール

# cd /usr/local/src/mysql-5.6.14
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
→ CMakeCache.txt削除し忘れ
# rm CMakeCache.txt 
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make
# make install

4.初期設定

グループ、ユーザ作成

# groupadd mysql
# useradd -g mysql -d /usr/local/mysql mysql

データディレクトリを追加

# sudo mkdir /var/lib/mysql
# mkdir /var/lib/mysql
# chown -R mysql:mysql /usr/local/mysql

初期化

# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql -basedir=/usr/local/mysql 

所有者変更

# chown mysql:mysql -R /var/lib/mysql/*

起動スクリプト作成

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

起動

# /usr/local/mysql/bin/mysql -u root 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
→ エラー発生

設定ファイルを編集

# vi /etc/my.conf
[mysqld]
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock

MySQL再起動

# /etc/init.d/mysqld restart

再度接続

/usr/local/mysql/bin/mysql -u root
接続を確認

パスワード設定

mysql> SET PASSWORD FOR root@localhost=PASSWORD('xxxxxxxxx');

5.ブラウザからの動作確認

ドキュメントルートに下記ファイルを配置

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>MySQL Databases</title>
</head>
<body>
<?php
$conn = new mysqli('localhost', 'root', 'xxxxxxxxx');
if (!$conn) {
    die('データベース接続エラー: ' . mysql_error());
}
$stmt = $conn->prepare("SHOW DATABASES");
$stmt->execute();

$stmt->bind_result($database);
while ($stmt->fetch()) {
     echo $database;
      echo "<br>";
}
?>
</body>
</html>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした