Penrose连接Mysql解决方案
最近一直在进行Penrose连接Mysql的尝试,可总是提示无法连接到Mysql,无论是检查端口是否开启,设置Mysql远程访问权限等都不管用,后来在Penrose的官网找到一个建立样例数据库及设置远程连接的文档,没想到一举成功,痛快啊!
下面就把文档和大家共享一下!(是英文,大家就凑合着看下吧!因为最近搞Penrose太累了,懒的再去翻译了!)
我安装的Penrose版本是2.0的,Mysql是5.0
The following are the instructions to setup the sample database. The instructions were written for MySQL 4.x, but you can use other database systems.
Create Database
Make sure you have a MySQL server running on your local machine. Create a MySQL database called "penrose_demo". Exececute the following commands inside a MySQL client:
create database penrose_demo;
Create Database User
Create a MySQL user called "penrose" with password "penrose". Exececute the following commands inside a MySQL client:
grant all privileges on *.* to 'penrose'@'<hostname>' identified by 'penrose' with grant option;
grant all privileges on *.* to 'penrose'@'localhost' identified by 'penrose' with grant option;
grant all privileges on *.* to 'penrose'@'%' identified by 'penrose' with grant option;
注:主要是这边关于权限的设置导致我总是连接不成功!有高手能详细解释下不?
Change the <hostname> with your machine name.
Create Database Tables
Populate the database with the SQL script provided in PENROSE_HOME/samples/sql. Exececute the following commands inside a MySQL client:
use penrose_demo;
source PENROSE_HOME/samples/sql/example.sql;
注:此脚本在相应目录中没有,需自己准备sql脚本!可在mysql官网上下载到!
The script was written for MySQL 4.x. If you are using a different database system, you might need to modify the script.
相关文档:
1、PHP发送中文、Ajax接收
只需在php顶部加入一句:
header('Content-type: text/html;charset=GB2312');
xmlHttp会正确解析其中的中文。
2、Ajax发送中文、PHP接收
这个比较复杂:
Ajax中先用encodeURIComponent对要提交的中文进行编码
PHP中:
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//I ......
使用mysql又遇到问题了,这次是关于乱码的...
其实我也比较了解编码的问题,也知道乱码产生的原理,而且网上对mysql的乱码问题也有比较多的解答,
但是今天我遇到的这个乱码却比较奇怪,在when语句中产生了奇怪的乱码。
create table my_table(id int, name varchar(50), born DateTime);
insert into my_table val ......
mysql 截取某一个时间(datetime类型)的日期:
方法1:select date(row_name) from table_name where row = row1;
方法2:select left(row_name, 10) from table_name where row = row1;
方法3:select cast(row_name as char[10]) from table_name where row = row1;
取得某个日期的time_t数值:select unix_times ......
Mysql 中定义字段后的数据的用处:
int(1)和int(10)似乎没有什么差别,都表示最大四个字节的整型数据。
例如定义一个名字为test的表:
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`id` int(1) NOT NULL,
`ids` int(10) default NULL,
`c` char(1) default NULL,
`cs` ......
2009年10月30日 星期五 22:53
1, 查看MySQL
服务器配置信息
mysql> show variables;
mysql> show variables;
2, 查看MySQL服务器运行的各种状态值
mysql> show global status;
mysql> show global status;
3, 慢查询
mysql> show variables like '%slow%';
+--------------- ......