OpenWrt下PHP+Lighttpd+MySql安装

2013-9-27 lqy openwrt

先安装软件包

opkg update

opkg install php5 php5-cgi php5-fastcgi php5-mod-session php5-mod-pdo php5-mod-pdo-mysql php5-mod-mysql php5-mod-gd php5-mod-xml php5-mod-session php5-mod-zip php5-pecl-apc zoneinfo-core zoneinfo-asia

opkg install lighttpd lighttpd-mod-access lighttpd-mod-alias lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-proxy lighttpd-mod-redirect lighttpd-mod-rewrite

opkg install  zlib libmysqlclient uclibcxx libreadline libncursesw mysql-server libncurses zip unzip

MySQL配置

修改 /etc/my.cnf

tmpdir = /mnt/data/tmp/

输入

/usr/bin/mysql_install_db --force

这是创建默认的数据库,数据文件默认的地址是/mnt/data/mysql这个文件夹下

输入如下命令就可以正常启动mysql了

root@OpenWrt:~# /etc/init.d/mysqld start
Starting MySQL daemon... done

可以看到mysql已经成功启动了

当然我们也可以输入

/etc/init.d/mysqld stop

来关闭mysql,只是现在千万别输入这个命令关闭mysql!!!

输入如下命令创建mysql的密码
/usr/bin/mysqladmin -u root password 123456
或者
/usr/bin/mysqladmin -u root password '123456'

登陆数据库
mysql -u root -p

这个时候会提示你要密码。输入密码是没有任何提示符的。连*都没有哦。全看不见,盲操作之后成功进入数据库

如果一切正确你会看到的是

root@OpenWrt:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 877
Server version: 5.1.53 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

创建一个xxxx数据库
mysql> create database ucenter
    -> \g

记住这里一定要以\g结束,这个命令的意思就是传送你刚才输入的字符到数据库

查看数据库
mysql> show databases
    -> \g

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| ucenter            |
+--------------------+
4 rows in set (0.17 sec)

 

这个其实是可以不用做的

输入如下命令

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.1.53, for openwrt-linux-gnu (mips) using readline 5.2

Connection id:          879
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.53 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1

UNIX socket:            /var/run/mysqld.sock
Uptime:                 23 hours 8 min 53 sec

Threads: 1  Questions: 7974  Slow queries: 4  Opens: 894  Flush tables: 1  Open tables: 64 Queries per second avg: 0.95
--------------

你会看到当前数据库的一些状况!!!!




发表评论:

Powered by emlog