64bit windows 8 安装 32bit PowerDesinger并且连接mysql

安装PowerDesigner160;

安装mysql-odbc

给系统注册mysql-odbc, 下载[mysql-connector-odbc-noinstall-5.1.11-win32],以管理员方式运行[Install.bat]。因为PowerDesigner是32位版的,所以这个也要安装32位的。

运行[系统盘:\Windows\SysWOW64\odbcad32.exe]。  新建一个系统DSN,数据源驱动选择[MySQL ODBC 5.1 Driver]。






图:设置系统DSN


PowerDesigner→DataBase→ Connection  利用刚才新建的系统DSN就将powerdesigner和mysql连在一起来.



  图:powerdesigner使用系统DSN连接mysql


更改字符集

添加mysql的字符集ENGINE和DEFAULT CHARACTER SET 

工具栏-》database-》edit current DBMS


设置mysql自增长

当我们通过PowerDesigner设计MYSQL的表结构时,假如PD自动生成的SQL语句如下:

create table course(

   courseId int(10) unsigned not null auto_increment,

   account national varchar(10) not null,

   courseTime national varchar(200) not null,

   courseName national varchar(200)

);

alter table course comment 'InnoDB free: 2048 kB';

alter table course

add primary key (courseId);

此时在执行SQL代码时会报出:Incorrect table definition;there can be only auto column and it must be defined as a key,

这样的错误.其大概意思是说"想要创建自增的列,必须作为一个键定义".

通过检查SQL语句发现,在设置auto_increment的时候courseId 并不是主键,而是在创建完表结构之后,通过 alter table course add primary key (courseId);的方式创建表的主键,因此表course的自增长主键设置不成功.

解决办法:

1、打开PowerDesigner->数据库->Edit Current DBMS->Script->Objects->Table-Create

2、在左侧Value: 将%TABLDEFN%改为"%TABLDEFN%, primary key (%PKEYCOLUMNS%)" 点击"应用"

3、打开PowerDesigner->数据库->Edit Current DBMS->Script->Objects->PKAY->Enable,左侧Value:选择NO

此时PD生成的SQL脚本如下所示:

create table course

(
courseId int(10) unsigned not null auto_increment,
account national varchar(10) not null,
courseTime national varchar(200) not null,
courseName national varchar(200),

primary key(courseId)
);

alter table course comment 'InnoDB free: 2048 kB';



---------------

mysql的root账户,我在连接时通常用的是localhost或127.0.0.1,公司的测试服务器上的mysql也是localhost所以我想访问无法访问,测试暂停.

解决方法如下:

1,修改表,登录mysql数据库,切换到mysql数据库,使用sql语句查看"select host,user from user ;"

mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user ='root';
mysql>select host, user from user;
mysql>flush privileges;

注意:最后一句很重要,目的是使修改生效.如果没有写,则还是不能进行远程连接.

2,授权用户,你想root使用密码从任何主机连接到mysql服务器

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  IDENTIFIED BY 'qaz123'  WITH GRANT OPTION;
flush privileges;

如果你想允许用户root从ip为192.168.1.104的主机连接到mysql服务器

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104'   IDENTIFIED BY 'admin123'  WITH GRANT OPTION; 
flush privileges;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值