$ su
# groupadd mysql
# useradd -g mysql mysql
# exit
$ tar xzf mysql-5.0.22.tar.gz
$ cd mysql-5.0.22
mysql-5.0.22$ ./configure --prefix=/usr/local/mysql
mysql-5.0.22$ make
mysql-5.0.22$ su
mysql-5.0.22# make install
mysql-5.0.22# cp -p support-files/my-medium.cnf /etc/my.cnf
mysql-5.0.22# cd /usr/local/mysql
/usr/local/mysql# ./bin/mysql_install_db --user=mysql
/usr/local/mysql# chown -R root .
/usr/local/mysql# chown -R mysql var
/usr/local/mysql# chgrp -R mysql .
/usr/local/mysql# cp -p ./share/mysql/mysql.server /etc/rc.d/init.d/.
/usr/local/mysql# /sbin/chkconfig --add mysql.server
/usr/local/mysql# exit
mysql-5.0.22$ /usr/local/mysql/bin/mysqladmin -u root password Password MySQL 管理者のパスワードを設定
mysql-5.0.22$ /usr/local/mysql/bin/mysql -u root -p mysql MySQL にユーザを追加
mysql-5.0.22$ /usr/local/mysql/bin/mysqladmin -u root -p reload
insert into user set host='localhost', user='who',password=Password('password'), Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', Create_priv='Y';
mysql-5.0.22$ cd
$
$ echo "SHOW DATABASES" | /usr/local/mysql/bin/mysql -t・ユーザに DB とアカウントを用意してみる
$ echo "CREATE TABLE test_table ( id INTEGER, value VARCHAR(10) )" | /usr/local/mysql/bin/mysql test+--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+
$ echo "SHOW TABLES" | /usr/local/mysql/bin/mysql test -t
$ echo "SHOW FULL COLUMNS FROM test_table" | /usr/local/mysql/bin/mysql test -t+----------------+ | Tables_in_test | +----------------+ | test_table | +----------------+
$ echo "INSERT INTO test_table (id,value) VALUES (1,'aaa')" | /usr/local/mysql/bin/mysql test+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+ | id | int(11) | NULL | YES | | NULL | | select,insert,update,references | | | value | varchar(10) | latin1_swedish_ci | YES | | NULL | | select,insert,update,references | | +-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
$ echo "INSERT INTO test_table (id,value) VALUES (2,'bbb')" | /usr/local/mysql/bin/mysql test
$ echo "SELECT * FROM test_table" | /usr/local/mysql/bin/mysql test -t
+------+-------+ | id | value | +------+-------+ | 1 | aaa | | 2 | bbb | +------+-------+
$ /usr/local/mysql/bin/mysql -u root -p mysql
mysql> create database DataBaseName ;
mysql> insert into user set host='localhost', user='UserName',password=Password('Password'), Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', Create_priv='Y' ;
mysql> grant create,drop,select,insert,update,delete
on DataBaseName.* to UserName@localhost identified by 'Password' ;
$ php-5.1.4.tar.gz
$ cd php-5.1.4
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring
$ make
# make install
# vi /usr/local/apache2/conf/httpd.conf
# cp ./php.ini-dist /usr/local/lib/php.ini
LoadModule php4_module modules/libphp4.so <- 自動的に追加されます
AddType application/x-httpd-php .php .phtml
# vi /usr/local/lib/php.ini
# /usr/local/apache2/bin/apachectl stop
include_path = ".:/usr/local/lib/php"
# /usr/local/apache2/bin/apachectl start
# vi /usr/local/apache2/htdocs/test.php
<html>
<?php phpinfo()?>
</html>
# vi /usr/local/apache2/htdocs/test.php
ブラウザから実行結果を確認
<html> <body> <?php $db = mysql_connect("localhost", "root", "password"); mysql_select_db("test",$db); $r = mysql_query("SELECT * FROM test_table",$db); while ($row = mysql_fetch_row($r)) { printf("%s,%s<br>\n", $row[0],$row[1]) ; } mysql_close($db) ; ?> </body> </html>
1,aaa
2,bbb