2014年10月29日 星期三

Raspberry Pi 上小米随身wifi的无线网卡应用

RUN rpi-update
创建src目录:
mkdir rpi_src
下载rpi-linux头文件:
cd rpi_src
git clone --depth 1 git://github.com/raspberrypi/linux.git rpi-linux
下载firmware
git clone --depth 1 git://github.com/raspberrypi/firmware.git rpi-firmware
下载小米随身wif驱动源码,小米的芯片是ralink的MT7601U,去官网(http://www.mediatek.com/en/downloads/)
下载,我这下的是DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2,
a)解压:
tar -xjvf DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2 得到DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
b) cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
c) 修改common/rtusb_dev_id.c文件,
  添加小米wifi的pid(可以通过lsusb得到:“Bus 001 Device 004: ID 2717:4106 ”):
{USB_DEVICE(0x2717,0x4106)}, /* Xiaomi Wifi */
d)修改Makefile:
   找到ifeq ($(PLATFORM),PC)处的 “LINUX_SRC”,把它改成指向 "rpi-linux" 的目录,这个很关键,我是从文件
“sta_ate_iwpriv_usage.txt” 中看到的;
编译、安装:
 cd ../rpi-linux
make mrproper
zcat /proc/config.gz > .config
make modules_prepare
cp ../rpi-firmware/extra/Module.symvers .
cd ../DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
make
sudo make install
sudo modprobe mt7601Usta
运行iwconfig,看到它了:
ra0       Ralink STA  ESSID:"11n-AP"  Nickname:"MT7601STA"
          Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated
          Bit Rate:1 Mb/s
          RTS thr:off   Fragment thr:off
          Link Quality=10/100  Signal level:0 dBm  Noise level:0 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
lo        no wireless extensions.
eth0      no wireless extensions.
配置Raspberry Pi无线网卡:
修改 /etc/network/interfaces 文件(这个文件是定义网络配置的):
sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto ra0
allow-hotplug ra0
iface ra0 inet dhcp
wpa-ssid "wifi"
wpa-psk "passwd"
TIPS:
auto lo //表示使用localhost
iface eth0 inet dhcp //表示如果有网卡ech0, 则用dhcp获得IP地址 (这个网卡是本机的网卡,而不是WIFI网卡)
auto ra0 //表示如果有wlan设备,使用ra0设备名
allow-hotplug ra0 //表示ra设备可以热插拨
iface ra0 inet dhcp //表示如果有WLAN网卡ra0 (就是WIFI网卡), 则用dhcp获得IP地址
wpa-ssid "wifi" //表示连接SSID名为 wifi的WIFI网络。 JoStudio是我的WIFI网SSID名称,如果是别的,请更改
wpa-psk "passwd" //表示连接WIFI网络时,使用wpa-psk认证方式,认证密码是passwd。如果是别的密码,请更改
设完restart,ifconfig就可看到ra0的连接,enjoy it!

Raspberry Pi – hiding boot messages on screen

http://ananddrs.com/2013/09/18/rpi-hide-boot-msg/

https://github.com/Mashpy/Qt-MySQL-Driver-For-Windows





























fromhttp://www.raspberrypi.org/phpBB3/viewtopic.php?t=13807&p=153177


Qt入門篇(3):連結SQLITE資料庫

http://chenglearning.blogspot.tw/2013/11/qt3sqlite.html

MySQL跨主機查詢
在mysql 裏,預設的帳號所在的主機都是 localhost,這在db和web同一台主機時沒問題,但是如果資料庫是在不同的主機,就需要給予適當的權限。

例如:

web 主機的ip是 192.168.0.2

mysql 主機 ip 是 192.168.0.3

0,先確認雙方的防火牆沒有檔到3306 post!

1,先確認192.168.0.3的3306 port是不是打開?

使用nestat命令查看3306 port狀態:

~# netstat -an | grep 3306

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

由此可以看出3306 port只是在IP 127.0.0.1上監聽,拒絕其他IP的訪問。

3,請修改/etc/mysql/my.cnf文件:

# Instead of skip-networking the default is now to listen only on

# localhost which is more compatible and is not less secure.

bind-address = 127.0.0.1

把上面這一行註釋掉或者把127.0.0.1換成合適的IP,或直接註釋掉。

/etc/init.d/mysql restart
重新啟動後,重新使用netstat檢測:

~# netstat -an | grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

由此可看到MySQL已開始監聽3306 post所有對外的封包。

4,在[192.168.0.2]使用下面命令測試:

 ~# mysql -h 192.168.0.3 -u root -p

Enter password:

ERROR 1130 (00000): Host 'Ubuntu_pc.local' is not allowed to connect to this MySQL server

則還需要mysql把用戶權限分配各遠端用戶。

請登錄到mysql所在伺服器,使用grant命令分配權限

mysql> grant all on database_name.* to user_name@'%' identified by 'user_password';

其中database_name、user_name和user_password根據實際情況設置。

完成後使用mysql命令連接,提示成功,為了確保正確可以再遠端登錄測試一下。

# mysql -u root -p

grant all on db_name.* to db_user@192.168.0.2 identified by 'db_pass';

quit

退出mysql,那麼在 192.168.0.2 的 db_user 這個帳號就可以存取 192.168.0.3 上的 db_name 資料庫

而在 mysql_connect() 裏的 localhost ,就用 192.168.0.3 來取代就可以了 !

如果遇到登入過久的問題,則可以把MySQL的DNS反查功能關閉!
sudo vim /etc/mysql/my.cnf
在[mysqld]下面新增一行:
skip-name-resolve 
sudo /etc/init.d/mysql restart
重開即可解決!

Qt is now configured for building. Just run mingw32-make.
To reconfigure, run mingw32-make confclean and configure.

C:\Qt\4.7.2>configure -qt-sql-mysql -plugin-sql-mysql -nomake demos -nomake examples
                     configure -debug-and-release -qt-sql-mysql
C:\Qt\4.7.2>mingw32-make

用 root 登入 MySQL
  mysql -u root -p
 Enter password:  
 
mysql> GRANT all ON db35.* TO s35@'localhost' IDENTIFIED BY 's35'; 
   把 db35 這個資料庫(含其下的所有資料表),授權給 s35,從 localhost 上來,密碼為s35
 
mysql> GRANT all ON *.*  把所有資料庫及資料表授權給別人,太危險了!
 
mysql> GRANT all??? ON www.* TO '*'@'*' IDENTIFIED BY '';
    把 www 這個資料庫(含其下的所有資料表),授權給 任何機器任何人,無密碼(通常給不特定人士使用)
 
mysql> FLUSH PRIVILEGES;   (最後一定要強迫更新權限)

 
mysql>create database TestDB;

 mysql>grant all on TestDB.* to U517@'%' IDENTIFIED BY 'Abc123';

首先使用 root 的權限
visudo  ( vi /etc/sudoers )
將最後一行的
%admin ALL=(ALL) ALL
改成

%admin ALL=(ALL) NOPASSWD: NOPASSWD: ALL
存檔退出,即可。

2. 7z命令的使用
2.1 解压缩7z文件
7za x phpMyAdmin-3.3.8.1-all-languages.7z -r -o./
参数含义:
x  代表解压缩文件,并且是按原始目录树解压(还有个参数 e 也是解压缩文件,但其会将所有文件都解压到根下,而不是自己原有的文件夹下)
phpMyAdmin-3.3.8.1-all-languages.7z  是压缩文件,这里我用phpadmin做测试。这里默认使用当前目录下的phpMyAdmin-3.3.8.1-all-languages.7z
-r 表示递归解压缩所有的子文件夹
-o 是指定解压到的目录,-o后是没有空格的,直接接目录。这一点需要注意。

2.2 压缩文件/文件夹

7za a -t7z -r Mytest.7z /opt/phpMyAdmin-3.3.8.1-all-languages/*
参数含义:
a  代表添加文件/文件夹到压缩包
-t 是指定压缩类型,这里定为7z,可不指定,因为7za默认压缩类型就是7z。
-r 表示递归所有的子文件夹
Mytest.7z 是压缩好后的压缩包名
/opt/phpMyAdmin-3.3.8.1-all-languages/*:是压缩目标。
注意:7za不仅仅支持.7z压缩格式,还支持.tar.bz2等压缩类型的。如上所述,用-t指定即可。

Install lamp with 1 command in Ubuntu 12.10, 13.04

http://www.unixmen.com/install-lamp-with-1-command-in-ubuntu-1010-maverick-meerkat/

    Qt SQL Database Drivers 設定

    http://qt-project.org/doc/qt-4.8/sql-driver.html

Qt5程序在Windows 7/8上部署注意事项


http://www.aiuxian.com/article/p-496281.html

http://blog.csdn.net/zgj10086/article/details/19681633
http://blog.csdn.net/listenape/article/details/22039619
  • WpaSupplicant
    • http://wiki.centos.org/zh-tw/HowTos/Laptops/WpaSupplicant

      http://qt-project.org/forums/viewthread/16378

2014年10月18日 星期六

node.js教學-操作MySQL資料庫

http://blog.allenchou.cc/nodejs-tuts-5-use-mysql-db/

Qt入門篇(1)

http://chenglearning.blogspot.tw/2013/11/qt1-qt-gui-application.html

Raspberry Pi – hiding boot messages on screen

There may be a time when one would want to hide boot messages that show up on the screen (or monitor or TV). The trick is to edit /boot/cmdline.txt file.
One may use the following command
sudo nano /boot/cmdline.txt
Then make the following changes to the file:
- Replace "console=tty1" by "console=tty3" to redirect boot messages to the third console.
- Add "loglevel=3" to disable non-critical kernel log messages.
After changing, to get to the console simply press Alt + F3 during or after boot. However, if text cursor needs to be hidden also then add “vt.global_cursor_default=0″ to the /boot/cmdline.txt file. In my case, I prefer to have text cursor as an indicator that it is actually booting.
Here is the content of my /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait logo.nologo loglevel=3
This is a quick and dirty solution for an unanimated custom splash screen during boot.
First of all, you need to install fbi:
apt-get install fbi
Copy your custom splash image to /etc/ and name it “splash.png”.
Next, create an init.d script called “asplashscreen” in “/etc/init.d/”.
I chose “asplashscreen” with an “a” at the beginning to be sure it starts first.
#! /bin/sh
### BEGIN INIT INFO
# Provides:          asplashscreen
# Required-Start:
# Required-Stop:
# Should-Start:      
# Default-Start:     S
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description:       Show custom splashscreen
### END INIT INFO

do_start () {

    /usr/bin/fbi -T 1 -noverbose -a /etc/splash.png    
    exit 0
}

case "$1" in
  start|"")
    do_start
    ;;
  restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
  stop)
    # No-op
    ;;
  status)
    exit 0
    ;;
  *)
    echo "Usage: asplashscreen [start|stop]" >&2
    exit 3
    ;;
esac
Then make that script executable and install it for init mode rcS:
chmod a+x /etc/init.d/asplashscreen
insserv /etc/init.d/asplashscreen
Reboot and watch your custom splash screen:
reboot

Linux下MySQL 5.5的修改字符集编码为UTF8(彻底解决中文乱码问题)

http://www.ha97.com/5359.html

sudo cp mt7601Usta.ko /lib/modules/3.12.28+/kernel/drivers/net/wireless/
sudo depmod -a
sudo reboot

Install Adminer manually on Ubuntu 14.04

http://www.leaseweblabs.com/2014/06/install-adminer-manually-ubuntu-14-04/


How To Install Linux, Apache, MySQL, PHP (LAMP)  on buntu

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu