投げ銭

★当サイトへの投げ銭(PayPal)★

LINK


(無償、寄付歓迎) logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)

★LibreOfficeの導入事例★
詳細について

人気の投稿(1ヶ月間)

Ad

Ad

投げ銭

★当サイトへの投げ銭(PayPal)★

2011年11月29日火曜日

【Linux CentOS 5.7】【MYSQL 5.0.77】 MySQL Connector/Jを使ったクライアントから接続できるようMYSQLサーバー側にコネクターをインストールする

「Connector/Jを使ったクライアントから接続できるようMYSQLサーバー側にコネクターをインストールする」

JDBC driver(= MySQL Connector/J)を用いたクライアントアプリケーションからMYSQLへ接続するためには、
MYSQLサーバー側でもコネクターをインストールしている必要がある。
これは、そのインストール手順のメモである。


<前提> 
・OSは、CentOS 5.7 64bit版である。

対象にしたMYSQLのバージョンは5.0.77であり、
これは、YUMを使って次の手順でインストールし、初期設定を済ませている
http://akira-arets.blogspot.com/2011/11/linux-centos-57-mysqlyum.html



<方法>
前提であげたMYSQLサーバーがインストールされているマシンにおいて、
mysql-connector-javaというパッケージをYUMを使ってインストールする。

mysql-connector-javaというパッケージは、epelリポジトリに存在しているので、
先ず、epelリポジトリが利用できる状態にしておく必要がある。

(注意)
クライアントがリモートに存在する場合は、
さらに、MYSQLサーバー側でリモートアクセスを許可する設定が必要になる



<手順>
■epelリポジトリをyumリポジトリとして登録した
[root@localhost ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm を取得中
警告: /var/tmp/rpm-xfer.XXXXX: ヘッダ V3 DSA signature: NOKEY, key ID
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

[root@localhost ~]#

□mysql-connector-javaについて情報を表示させる
[root@localhost ~]# yum info mysql-connector-java
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
Available Packages
Name       : mysql-connector-java
Arch       : x86_64
Epoch      : 1
Version    : 5.1.12
Release    : 2.el5
Size       : 2.5 M
Repo       : epel
Summary    : Official JDBC driver for MySQL
URL        : http://dev.mysql.com/downloads/connector/j/
License    : GPLv2 with exceptions
Description: MySQL Connector/J is a native Java driver that converts JDBC (Java Database
           : Connectivity) calls into the network protocol used by the MySQL database.
           : It lets developers working with the Java programming language easily build
           : programs and applets that interact with MySQL and connect all corporate
           : data, even in a heterogeneous environment. MySQL Connector/J is a Type
           : IV JDBC driver and has a complete JDBC feature set that supports the
           : capabilities of MySQL.

[root@localhost ~]#

■インストール作業を行った
[root@localhost ~]# yum install mysql-connector-java
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies

========================================================================================================================================================================
 Package                                           Arch                          Version                                              Repository                   Size
========================================================================================================================================================================
Installing:
 mysql-connector-java                              x86_64                        1:5.1.12-2.el5                                       epel                        2.5 M
Installing for dependencies:
 antlr                                             x86_64                        2.7.6-4jpp.2                                         base                        1.1 M
 axis                                              x86_64                        1.2.1-2jpp.6                                         base                        3.6 M
 bcel                                              x86_64                        5.1-8jpp.1                                           base                        1.1 M
 classpathx-jaf                                    x86_64                        1.0-9jpp.1                                           base                        111 k
 classpathx-mail                                   x86_64                        1.1.1-4jpp.2                                         base                        1.2 M
 geronimo-specs                                    x86_64                        1.0-0.M2.2jpp.12.el5.centos                          base                        259 k
 geronimo-specs-compat                             x86_64                        1.0-0.M2.2jpp.12.el5.centos                          base                        5.5 k
 gjdoc                                             x86_64                        0.7.7-12.el5                                         base                        886 k
 jakarta-commons-discovery                         x86_64                        1:0.3-4jpp.1                                         base                        150 k
 jakarta-commons-httpclient                        x86_64                        1:3.0-7jpp.1                                         base                        596 k
 jakarta-commons-logging                           x86_64                        1.0.4-6jpp.1                                         base                        115 k
 java-1.4.2-gcj-compat                             x86_64                        1.4.2.0-40jpp.115                                    base                         29 k
 jpackage-utils                                    noarch                        1.7.3-1jpp.2.el5                                     base                         61 k
 libXtst                                           x86_64                        1.0.1-3.1                                            base                         16 k
 libart_lgpl                                       x86_64                        2.3.17-4                                             base                         75 k
 libgcj                                            x86_64                        4.1.2-51.el5                                         base                         18 M
 log4j                                             x86_64                        1.2.13-3jpp.2                                        base                        728 k
 mx4j                                              x86_64                        1:3.0.1-6jpp.4                                       base                        2.7 M
 regexp                                            x86_64                        1.4-2jpp.2                                           base                        102 k
 tomcat5-servlet-2.4-api                           x86_64                        5.5.23-0jpp.19.el5_6                                 base                        163 k
 wsdl4j                                            x86_64                        1.5.2-4jpp.1                                         base                        429 k
 xml-commons                                       x86_64                        1.3.02-0.b2.7jpp.10                                  base                         19 k
 xml-commons-apis                                  x86_64                        1.3.02-0.b2.7jpp.10                                  base                        388 k
 xml-commons-resolver                              x86_64                        1.1-1jpp.12                                          base                        170 k

Transaction Summary
========================================================================================================================================================================
Install      25 Package(s)
Upgrade       0 Package(s)

Total download size: 34 M

Installed:
  mysql-connector-java.x86_64 1:5.1.12-2.el5

Dependency Installed:
  antlr.x86_64 0:2.7.6-4jpp.2                                axis.x86_64 0:1.2.1-2jpp.6                            bcel.x86_64 0:5.1-8jpp.1
  classpathx-jaf.x86_64 0:1.0-9jpp.1                         classpathx-mail.x86_64 0:1.1.1-4jpp.2                 geronimo-specs.x86_64 0:1.0-0.M2.2jpp.12.el5.centos
  geronimo-specs-compat.x86_64 0:1.0-0.M2.2jpp.12.el5.centos gjdoc.x86_64 0:0.7.7-12.el5                           jakarta-commons-discovery.x86_64 1:0.3-4jpp.1
  jakarta-commons-httpclient.x86_64 1:3.0-7jpp.1             jakarta-commons-logging.x86_64 0:1.0.4-6jpp.1         java-1.4.2-gcj-compat.x86_64 0:1.4.2.0-40jpp.115
  jpackage-utils.noarch 0:1.7.3-1jpp.2.el5                   libXtst.x86_64 0:1.0.1-3.1                            libart_lgpl.x86_64 0:2.3.17-4
  libgcj.x86_64 0:4.1.2-51.el5                               log4j.x86_64 0:1.2.13-3jpp.2                          mx4j.x86_64 1:3.0.1-6jpp.4
  regexp.x86_64 0:1.4-2jpp.2                                 tomcat5-servlet-2.4-api.x86_64 0:5.5.23-0jpp.19.el5_6 wsdl4j.x86_64 0:1.5.2-4jpp.1
  xml-commons.x86_64 0:1.3.02-0.b2.7jpp.10                   xml-commons-apis.x86_64 0:1.3.02-0.b2.7jpp.10         xml-commons-resolver.x86_64 0:1.1-1jpp.12

Complete!
[root@localhost ~]#

MYSQLサーバーに対するコネクターのインストール作業はこれで完了した。
構成などは自動的にされているようで、問題なくクライアントからアクセスることが出来た。

ただし、クライアントがリモートに存在する場合は、
さらにMYSQLサーバー側でリモートアクセスを許可する設定が必要になる。

【MySQL 5.0.77】 リモートからのアクセスを許可する設定方法

ネットワーク上のリモートマシンからMySQLサーバーに接続するためには、MySQLサーバーで設定が必要になる。

mysqlコマンドプロンプトでGRANT文をユーザーごとに発行することで、ユーザーごとにリモートアクセスが許可された。
リモートアクセスの許可に伴ってそのユーザーに与える権限も指定する必要がある。

<手順>

■まず、mysqlコマンドプロンプトを起動する
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

■GRANT文を次のように発行して、指定したリモートユーザーを許可し、例えば全ての権限を与える場合の設定
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'192.168.0.0/255.255.0.0' IDENTIFIED BY "ここに対象ユーザーのパスワードを入力";
Query OK, 0 rows affected (0.00 sec)
mysql>
(コマンドの意味)
・ALL PRIVILEGES ON *.*
全てのデータベースとそのテーブルに対する、全ての権限を意味する

・root@'192.168.0.0/255.255.0.0'
指定したサブネットからアクセスするrootユーザーを意味する


これによって、直ちにリモートアクセスが可能になった
言うまでもなく、ファイヤーウォールなどのpass設定は別に必要になってくる。



□また例えば、指定したリモートユーザーを許可し、「SELECT」操作だけを許可する場合の設定
mysql> GRANT SELECT ON *.* TO username@'192.168.0.0/255.255.0.0' IDENTIFIED BY "ここに対象ユーザーのパスワードを入力";
Query OK, 0 rows affected (0.00 sec)


(参照)
How can I setup a remote connection to MySQL?
< http://help.hardhathosting.com/question.php/87 > 2011/11/29

2011年11月26日土曜日

【MYSQL 5.0.77】 相関クエリ内でdeleteできないこと、サブクエリと同一名のテーブルの行をメインクエリでdeleteできないこと

◎以下の操作は全て、phpMyAdmin - 2.11.11.3のSQL文発行機能をMYSQL 5.0.77に対して用いて行った。

相関クエリで行をdeleteできなかったことと、
サブクエリとメインクエリとで使っている同一名のテーブルについて、その行をメインクエリでdeleteできなかったことについて



先ず、次の相関クエリは通って結果を得ることができた。
select * from TMPADR t1
where t1.id > ( select min(t2.id) from TMPADR t2 where t1.number = t2.number )
しかし、これらの該当行を削除しようとする次のdelete相関クエリはエラーが発生して通らなかった。
delete from TMPADR t1
where t1.id > ( select min(t2.id) from TMPADR t2 where t1.number = t2.number )


相関クエリのサブクエリで用いているテーブルと同名のテーブルを、
メインクエリでdelete文の対象にしているためにエラーが生じるのかと考えて、
サブとメインとで異なるテーブルを用いる次の相関クエリを作成した。

TMPADRと、tmpadr2は全く同じ内容のテーブルである。
delete from TMPADR t1
where t1.id > ( select min(t2.id) from tmpadr2 t2 where t1.number = t2.number )
しかし、次のエラーが発生してdelete相関クエリは通らなかった。
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where t1.id &gt; ( select min(t2.id) from tmpadr2 t2 where t1.number = t2.number )' at line 2 


①のクエリは通ったことから、
とりあえず、①の相関クエリの結果をWHERE句で指定し、相関クエリの外でDELETEしてみようとした。

先ず、DELETE文の代わりにSELECT文を次のように発行してみると、
クエリは通り、結果が返された。
SELECT * FROM TMPADR WHERE id IN (
  SELECT id FROM TMPADR t1 WHERE t1.id > (
    SELECT min(t2.id) FROM TMPADR t2 WHERE t1.number = t2.number )
)


つづいて、該当する行を削除する次のクエリを作成したが、またエラーが発生した。
DELETE FROM TMPADR WHERE id IN (
  SELECT id FROM TMPADR t1 WHERE t1.id > (
    SELECT min(t2.id) FROM TMPADR t2 WHERE t1.number = t2.number )
)
次のエラーが発生した。
#1093 - You can't specify target table 'TMPADR' for update in FROM clause 
そこで、DELETE文を発行しているメインクエリと、サブクエリである相関クエリで、同じテーブルを用いないようにしてみた。
TMPADRテーブルの複製を、tmpadr2テーブルとして作成した。
DELETE FROM TMPADR WHERE id IN (
  SELECT id FROM tmpadr2 t1 WHERE t1.id > (
    SELECT min(t2.id) FROM tmpadr2 t2 WHERE t1.number = t2.number )
)

すると、ようやく、クエリを受け付けてもらえて、該当行が削除された。


(まとめ)
MYSQL(5.0.77)+phpMyAdmin - 2.11.11.3で次のことができなかった。
・相関クエリでは、該当行を削除するdeleteを発行することができなかった。( ③のクエリ )
・サブクエリで使っている同じ名前のテーブルの行は、メインクエリからdeleteすることができなかった。( ⑤のクエリ )

相関クエリやサブクエリで扱われるテーブルは別名を与えたとしても、主クエリではselectすることはできるがその行をdeleteできなかったということになると思う。

これが標準的なSQLの動作なのかどうかはよくわからない。

2011年11月21日月曜日

【Linux CentOS 5.7】 phpMyAdminをYUMでインストールする

CentOS 5.7 64bit版に、phpMyAdminをYUMでインストールする手順メモ


phpMyAdminは、MySQLサーバーを管理・操作するためのGUIインターフェイスを提供する。
httpdと協調して動作するので、ユーザーはブラウザから扱うことができる。


<前提として>
MySQLが次の手順でインストールできていて、同一マシンにphpMyAdminをインストールすることとする。
http://akira-arets.blogspot.com/2011/11/linux-centos-57-mysqlyum.html



■システムのアップデートを行った
[root@localhost ~]# yum update
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-274.7.1.el5 #1 SMP Thu Oct 20 16:21:01 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux


■epelリポジトリを追加する
phpMyAdminは、標準のリポジトリには入っていない。epelリポジトリを追加しておく。
[root@localhost ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm を取得中
警告: /var/tmp/rpm-xfer.XXXXX: ヘッダ V3 DSA signature: NOKEY, key ID
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@localhost ~]#


□phpMyAdminの情報を表示させる
[root@localhost ~]# yum info phpMyAdmin
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp

Available Packages
Name       : phpMyAdmin
Arch       : noarch
Version    : 2.11.11.3
Release    : 2.el5
Size       : 4.2 M
Repo       : epel
Summary    : Handle the administration of MySQL over the World Wide Web
URL        : http://www.phpmyadmin.net/
License    : GPLv2+
Description: phpMyAdmin is a tool written in PHP intended to handle the administration of
           : MySQL over the World Wide Web. Most frequently used operations are supported
           : by the user interface (managing databases, tables, fields, relations, indexes,
           : users, permissions), while you still have the ability to directly execute any
           : SQL statement.


■phpMyAdminをインストールする
依存関係にあるhttpdや、phpなどもインストールされた。
[root@localhost ~]# yum install phpMyAdmin
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
========================================================================================================================================================================
 Package                                    Arch                              Version                                          Repository                          Size
========================================================================================================================================================================
Installing:
 phpMyAdmin                                 noarch                            2.11.11.3-2.el5                                  epel                               4.2 M
Installing for dependencies:
 GeoIP                                      x86_64                            1.4.8-1.el5                                      epel                               783 k
 apr                                        x86_64                            1.2.7-11.el5_6.5                                 base                               119 k
 apr-util                                   x86_64                            1.2.7-11.el5_5.2                                 base                                79 k
 gd                                         x86_64                            2.0.33-9.4.el5_4.2                               base                               155 k
 gmp                                        x86_64                            4.1.4-10.el5                                     base                               201 k
 httpd                                      x86_64                            2.2.3-53.el5.centos.3                            updates                            1.2 M
 libXpm                                     x86_64                            3.5.5-3                                          base                                44 k
 libmcrypt                                  x86_64                            2.5.8-4.el5.centos                               extras                             105 k
 libxslt                                    x86_64                            1.1.17-2.el5_2.2                                 base                               488 k
 nginx                                      x86_64                            0.8.55-1.el5                                     epel                               389 k
 php                                        x86_64                            5.1.6-27.el5_5.3                                 base                               2.3 M
 php-cli                                    x86_64                            5.1.6-27.el5_5.3                                 base                               2.2 M
 php-common                                 x86_64                            5.1.6-27.el5_5.3                                 base                               153 k
 php-gd                                     x86_64                            5.1.6-27.el5_5.3                                 base                               118 k
 php-mbstring                               x86_64                            5.1.6-27.el5_5.3                                 base                               1.0 M
 php-mcrypt                                 x86_64                            5.1.6-15.el5.centos.1                            extras                              16 k
 php-mysql                                  x86_64                            5.1.6-27.el5_5.3                                 base                                89 k
 php-pdo                                    x86_64                            5.1.6-27.el5_5.3                                 base                                66 k
 pkgconfig                                  x86_64                            1:0.21-2.el5                                     base                                61 k
 postgresql-libs                            x86_64                            8.1.23-1.el5_7.3                                 updates                            197 k

Transaction Summary
========================================================================================================================================================================
Install      21 Package(s)
Upgrade       0 Package(s)

Total download size: 14 M

 Installed:
  phpMyAdmin.noarch 0:2.11.11.3-2.el5

Dependency Installed:
  GeoIP.x86_64 0:1.4.8-1.el5              apr.x86_64 0:1.2.7-11.el5_6.5           apr-util.x86_64 0:1.2.7-11.el5_5.2        gd.x86_64 0:2.0.33-9.4.el5_4.2
  gmp.x86_64 0:4.1.4-10.el5               httpd.x86_64 0:2.2.3-53.el5.centos.3    libXpm.x86_64 0:3.5.5-3                   libmcrypt.x86_64 0:2.5.8-4.el5.centos
  libxslt.x86_64 0:1.1.17-2.el5_2.2       nginx.x86_64 0:0.8.55-1.el5             php.x86_64 0:5.1.6-27.el5_5.3             php-cli.x86_64 0:5.1.6-27.el5_5.3
  php-common.x86_64 0:5.1.6-27.el5_5.3    php-gd.x86_64 0:5.1.6-27.el5_5.3        php-mbstring.x86_64 0:5.1.6-27.el5_5.3    php-mcrypt.x86_64 0:5.1.6-15.el5.centos.1
  php-mysql.x86_64 0:5.1.6-27.el5_5.3     php-pdo.x86_64 0:5.1.6-27.el5_5.3       pkgconfig.x86_64 1:0.21-2.el5             postgresql-libs.x86_64 0:8.1.23-1.el5_7.3

Complete!
[root@localhost ~]#


■httpdを自動起動させる設定を行った
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig --list | grep httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off


■httpdの設定ファイルを変更した

先ず、設定ファイル変更の前にバックアップを取った。
[root@localhost ~]# cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.orig

設定ファイルを変更した。
下記のように赤文字列の行(Allow from 192.168.0.0/16)を追加し、
192.168.0.0/16ローカルサブネットからphpMyAdminにブラウザからアクセスできるようにした。

[root@localhost ~]# vim /etc/httpd/conf.d/phpMyAdmin.conf
(・・・省略)

<Directory /usr/share/phpMyAdmin/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
   Allow from ::1
   Allow from 192.168.0.0/16
</Directory>

<Directory /usr/share/phpMyAdmin/scripts/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
   Allow from ::1
   Allow from 192.168.0.0/16
</Directory>

(省略・・・)


■httpdを(再)起動させる
[root@localhost ~]# service httpd restart
httpd を停止中:                                            [失敗]
httpd を起動中:                                            [  OK  ]


■上で設定したローカルサブネット上のブラウザから、このマシンにHTTPで接続した

<例>192.168.X.YがphpMyAdminをインストールしたマシンだとすると、次のURLを使う。
http://192.168.X.Y/phpMyAdmin/index.php
すると、IDとパスワードの入力が求められたので、MySQLで設定したrootとパスワードを使った。
phpMyAdminのインターフェイスにアクセスすることができた。

2011年11月20日日曜日

【Linux CentOS 5.7】 MySQLをYUMでインストールする

CentOS 5.7 64bit版に、yumを使ってMySQLをインストールする手順メモ

 ■先ずシステムのアップデートを行った。
[root@localhost ~]# yum update
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux


■MySQLサーバーと、そのクライアントツールのインストールを行った。
[root@localhost ~]# yum install mysql-server mysql
========================================================================================================================================================================
 Package                                     Arch                                Version                                        Repository                         Size
========================================================================================================================================================================
Installing:
 mysql                                       i386                                5.0.77-4.el5_6.6                               base                              4.8 M
 mysql                                       x86_64                              5.0.77-4.el5_6.6                               base                              4.8 M
 mysql-server                                x86_64                              5.0.77-4.el5_6.6                               base                              9.8 M
Installing for dependencies:
 perl-DBD-MySQL                              x86_64                              3.0007-2.el5                                   base                              148 k
 perl-DBI                                    x86_64                              1.52-2.el5                                     base                              600 k

Transaction Summary
========================================================================================================================================================================
Install       5 Package(s)
Upgrade       0 Package(s)

Total download size: 20 M

Installed:
  mysql.i386 0:5.0.77-4.el5_6.6                       mysql.x86_64 0:5.0.77-4.el5_6.6                       mysql-server.x86_64 0:5.0.77-4.el5_6.6

Dependency Installed:
  perl-DBD-MySQL.x86_64 0:3.0007-2.el5                                                   perl-DBI.x86_64 0:1.52-2.el5

Complete!


■MySQLサーバーを自動起動させる設定を行う
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig --list | grep mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@localhost ~]#


■MySQLサーバーを起動する
初回では、案内のメッセージが表示された。
[root@localhost ~]# service mysqld start
MySQL データベースを初期化中:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

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 localhost.localdomain 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.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

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
                                                           [  OK  ]
MySQL を起動中:                                            [  OK  ]
[root@localhost ~]#


■MySQLサーバーのセットアップを行う
[root@localhost ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here
.

Enter current password for root (enter for none): ←インストールしたばかりで、MySQLのrootパスワードが未決定なので、そのままエンターを押す
 OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y ←MySQLのrootパスワードを設定したいので、Yを入力する。

New password: ←設定したいパスワードを入力する。
Re-enter new password: ←確認のため、再度入力する。
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y ←セキュリティーのため匿名ユーザーを許可しない場合は、Yを入力する。
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] ←rootユーザーのリモートログインを認めるなら、nを押す。
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n ←テスト用のデータベースを削除したくないなら、nを押す。
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y ←ここまでの設定内容を反映する場合は、Yを押す。
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@localhost ~]#


■MySQLサーバーにログインできるか試す
[root@localhost ~]# mysql -u root -p  ←rootユーザーでログインを試みる

Enter password: ←上のセットアップで設定したパスワードを入力する

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> exit ←mysqlのコマンドプロンプトを終了する
Bye
[root@localhost ~]#


◎MySQLの管理・操作GUIを提供するphpMyAdminのインストール方法はこちらです。
http://akira-arets.blogspot.com/2011/11/linux-centos-57-phpmyadminyum.html

2011年11月16日水曜日

【Linux CentOS 5.7】 epelリポジトリを追加する

CentOS5.7 64bit版に、epelリポジトリを追加する


rpmファイルは頻繁にアップデートされて名称が変わるので、下記コマンドにおいて、変更後の名称に置換する必要がある。
ブラウザなどでリンクにアクセスし、新しいepel-release・・・ファイルを探せば良い。

[root@localhost ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
あるいは、
[root@localhost ~]# rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm

http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm を取得中
警告: /var/tmp/rpm-xfer.XXXXX: ヘッダ V3 DSA signature: NOKEY, key ID
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

[root@localhost ~]#

投げ銭

★当サイトへの投げ銭(PayPal)★

Ad

Ad