> vi /var/db/process.sh
#呼叫MySQL StoreProcedure
#!/bin/sh
/usr/local/bin/mysql -uroot -prootpass -vvv -e "CALL TESTDB.pr_process_list()" > out.txt
-vvv : 可將訊息輸出到out.txt
或
usr/local/bin/mysql -uroot -prootpass -vvv < mysqlinputdata.txt > mysqloutputdata.txt
mysql執行mysqlinputdata.txt檔,並將訊息輸出到mysqloutputdata.txt
2010年4月27日 星期二
將processlist的筆數和資料存到資料庫內
DELIMITER $$
DROP PROCEDURE IF EXISTS `TESTDB`.`pr_process_list`$$
CREATE DEFINER=`root`@`%` PROCEDURE `TESTDB`.`pr_process_list`()
BEGIN
insert into TESTDB.processcount(num, create_date)
select COUNT(*) ,now()
from information_schema.PROCESSLIST;
insert into TESTDB.processlist(ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, create_date)
select ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO,now()
from information_schema.PROCESSLIST;
END $$
DELIMITER ;
呼叫MySQL StoreProcedure
mysql> CALL `TESTDB`.`pr_process_list`
DROP PROCEDURE IF EXISTS `TESTDB`.`pr_process_list`$$
CREATE DEFINER=`root`@`%` PROCEDURE `TESTDB`.`pr_process_list`()
BEGIN
insert into TESTDB.processcount(num, create_date)
select COUNT(*) ,now()
from information_schema.PROCESSLIST;
insert into TESTDB.processlist(ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, create_date)
select ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO,now()
from information_schema.PROCESSLIST;
END $$
DELIMITER ;
呼叫MySQL StoreProcedure
mysql> CALL `TESTDB`.`pr_process_list`
2010年4月20日 星期二
重設root密碼
用root登入,出現Access denied for user 'root'@'localhost'
解決方式:
1.進入ssh
sudo su -
2.停止mysql
> cd /usr/local/etc/rc.d/
> ./mysql-server stop
3啟動mysql
> mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
4.進入mysql
> mysql -u root mysql
5.更新 root 密碼
mysql> update user set password=PASSWORD('XXX') where user='root';
mysql> flush privileges;
mysql> exit;
6.重啟mysql
/usr/local/bin/mysqld_safe &
或
cd /usr/local/etc/rc.d/
./mysql-server restart
7.測試密碼
mysql -uroot -p
Enter password:
解決方式:
1.進入ssh
sudo su -
2.停止mysql
> cd /usr/local/etc/rc.d/
> ./mysql-server stop
3啟動mysql
> mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
4.進入mysql
> mysql -u root mysql
5.更新 root 密碼
mysql> update user set password=PASSWORD('XXX') where user='root';
mysql> flush privileges;
mysql> exit;
6.重啟mysql
/usr/local/bin/mysqld_safe &
或
cd /usr/local/etc/rc.d/
./mysql-server restart
7.測試密碼
mysql -uroot -p
Enter password:
2010年4月15日 星期四
改變檔案擁有者
chown [-R] 帳號名稱 檔案或目錄
chown [-R] 帳號名稱:群組名稱 檔案或目錄
ex:
# chown -R mysql:mysql /var/db/mysql
資料來源:
http://linux.vbird.org/linux_basic/0210filepermission.php#chown
chown [-R] 帳號名稱:群組名稱 檔案或目錄
ex:
# chown -R mysql:mysql /var/db/mysql
資料來源:
http://linux.vbird.org/linux_basic/0210filepermission.php#chown
2010年4月14日 星期三
MySQL的index重整
//mysql的update statisic
進ssh sudo -
# mysql -uXXX -p
//testtable指的是table name
mysql>optimize table testtable
進ssh sudo -
# mysql -uXXX -p
//testtable指的是table name
mysql>optimize table testtable
列出某個資料庫的所有table
//MySQL5
mysql> SELECT * FROM information_schema.`TABLES`;
或
show tables from DBNAME;
或
進入ssh
sudo su -
mysqlshow -uroot -p mysql
Database: mysql
+---------------------------+
| Tables |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
+---------------------------+
mysql> SELECT * FROM information_schema.`TABLES`;
或
show tables from DBNAME;
或
進入ssh
sudo su -
mysqlshow -uroot -p mysql
Database: mysql
+---------------------------+
| Tables |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
+---------------------------+
在ssh下sql語法
進入ssh
sudo su -
ex:找出mysql db 下的select語法
mysql -uroot -p -e "SELECT host, db,user from db" mysql
+------+---------+------+
| host | db | user |
+------+---------+------+
| % | test | |
| % | test\_% | |
+------+---------+------+
sudo su -
ex:找出mysql db 下的select語法
mysql -uroot -p -e "SELECT host, db,user from db" mysql
+------+---------+------+
| host | db | user |
+------+---------+------+
| % | test | |
| % | test\_% | |
+------+---------+------+
查詢MySQL 有多少資料庫
進入ssh
sudo su -
mysqlshow -uroot -ppasswd
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
sudo su -
mysqlshow -uroot -ppasswd
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
修改mysql登入的密碼
mysql>update mysql.user set password=PASSWORD('aaaa') where password = '';
mysql>flush privileges;
mysql>flush privileges;
2010年4月12日 星期一
FreeBSD查閱系統與核心相關資訊
uname -a
//查os版本
sysctl kern.ostype
=> kern.ostype: FreeBSD
sysctl kern.osrelease
=> 8.3-RELENG_8-20120624-JPSNAP
//查os版本
sysctl kern.ostype
=> kern.ostype: FreeBSD
sysctl kern.osrelease
=> 8.3-RELENG_8-20120624-JPSNAP
2010年4月8日 星期四
在FreeBSD中啟動MySQL
shell> sudo su -
shell> cd /usr/local/etc/rc.d/
shell> ./mysql-server start (開始)
shell> ./mysql-server stop (停止)
shell> ./mysql-server restart (重啟)
或
關閉 mysql 服務
shell> cd /usr/local/bin/
shell> ./mysqladmin shutdown -u -p<輸入密碼>
啟動 mysql 服務
shell> cd /usr/local/bin
shell> ./mysqld_safe &
shell> cd /usr/local/etc/rc.d/
shell> ./mysql-server start (開始)
shell> ./mysql-server stop (停止)
shell> ./mysql-server restart (重啟)
或
關閉 mysql 服務
shell> cd /usr/local/bin/
shell> ./mysqladmin shutdown -u
啟動 mysql 服務
shell> cd /usr/local/bin
shell> ./mysqld_safe &
2010年4月5日 星期一
取得radiobutton的值
javascript:
$("input[name='radiom']").click(function(){
var v = $("input[name='radiom'][@checked]").val();
alert(v);
});
html:
<input name="radiom" type="radio" value="1" checked="checked" />
<input name="radiom" type="radio" value="2" checked="checked" />
<input name="radiom" type="radio" value="3" checked="checked" />
$("input[name='radiom']").click(function(){
var v = $("input[name='radiom'][@checked]").val();
alert(v);
});
html:
<input name="radiom" type="radio" value="1" checked="checked" />
<input name="radiom" type="radio" value="2" checked="checked" />
<input name="radiom" type="radio" value="3" checked="checked" />
訂閱:
文章 (Atom)