免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4076 | 回复: 6
打印 上一主题 下一主题

linux下qt designer(3.1) 如何连接 mysql数据库! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-14 19:06 |只看该作者 |倒序浏览
qt designer 3.1 版本

我选择了project 下的 database connecitons...下, 点击了new connection .
Name:是默认的
driver:选择了QMYSQL3
hostname:localhost(本机)
port:defalut

点connect 出来提示框:
  could not connect to the database.
  please ensure that the database server is runing and that all the connection information is correct.
{mysql3:unable to connect
can't connext to local mysql server through socker '/var/lib/mysql/mysql.sock'(2)]

数据库服务器是开着的.我用的是xampp自带的mysql.

由于我的mysql.sock不在/var/lib/mysql/目录下,而是在 /opt/lampp/var/mysql/目录下.所以 can't connext to local mysql server through socker '/var/lib/mysql/mysql.sock'(2)
请问我怎么修改这个目录啊.谢谢!

我用的mysql是lampp 集成的一个,所以路径不是默认的/var/lib/mysql/mysql.sock'(2). 如果我把mysql.sock拷到这个目录,则出现错误如下:
Failed to open LHCDRecord database: QMYSQL3: Unable to connect
Client does not support authentication protocol requested by server; consider upgrading MySQL client
现在关键还是修改mysql.sock所在的路径. 谁会啊,帮了忙啊.谢了!呵呵

我的电脑里2有my.cnf ,2个php.ini 等. 一个在/etc/下,一个在/opt/lampp/etc/ 下.前面一个是系统自带的,另一个是我装xampp时产生的/etc/my.cnf中指定了mysql.sock的路径为: /var/lib/mysql/mysql.sock.而/var/lib/低下根本就没有mysql这个目录. /opt/lampp/etc/my.cnf指定了mysql.sock的路径为/opt/lampp/var/mysql/mysql.sock. (有)

我在kdevelop里也写了一个访问mysql数据库的程序,一切正常,包含了include,和lib .
到了qtdesigner里执行程序的时候用的就是/var/lib/mysql/mysql.sock,而这个文件不存在.所以错误.我该怎么办呢.
我把/opt/lampp/etc/my.cnf 拷贝到了/etc下代替原来的my.cnf.运行qt designer程序还是显示Failed to open LHCDRecord database: QMYSQL3: Unable to connect
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' ( 2)

在命令行登录到mysql -u .....
提示ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client
我一般不用命令行操作mysql数据库,用xampp自带的phpmyadmin图形界面


怎么让qtdesigner到/opt/lampp/var/mysql目录下找mysql.sock?????

论坛徽章:
0
2 [报告]
发表于 2005-11-16 13:41 |只看该作者
有没有人知道啊,帮忙一下啊,谢谢了

论坛徽章:
0
3 [报告]
发表于 2005-11-16 16:29 |只看该作者
文件问题你可以用 ln 做联结么;
然后的不能认证问题,就是经典的版本高低不匹配的问题了。

A.2.3 Client does not support authentication protocol

MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to it with an older client may fail with the following message:

shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client
To solve this problem, you should use one of the following approaches:

Upgrade all client programs to use a 4.1.1 or newer client library.
When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.
Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function:
mysql> SET PASSWORD FOR
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
Alternatively, use UPDATE and FLUSH PRIVILEGES:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
    -> WHERE Host = 'some_host' AND User = 'some_user';
mysql> FLUSH PRIVILEGES;
Substitute the password you want to use for ``newpwd'' in the preceding examples. MySQL cannot tell you what the original password was, so you'll need to pick a new one.
Tell the server to use the older password hashing algorithm:
Start mysqld with the --old-passwords option.
Assign an old-format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query:
mysql> SELECT Host, User, Password FROM mysql.user
    -> WHERE LENGTH(Password) > 16;
For each account record displayed by the query, use the Host and User values and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier.
For additional background on password hashing and authentication, see section 5.5.9 Password Hashing in MySQL 4.1.


例子:
SET PASSWORD FOR 用户名@localhost = OLD_PASSWORD('密码');

论坛徽章:
0
4 [报告]
发表于 2005-11-17 10:13 |只看该作者
按照你的方法我做了一个连接,然后就出现认证协议的问题: 按你说的解决方法 执行情况如下是怎么回事呢.谢谢!

[root@lhcd-server mysql]# mysql
ERROR 1045: Access denied for user 'root'@'localhost' (using password: NO)
[root@lhcd-server mysql]# mysql -u dxwang -plhcdlhcd
ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client
[root@lhcd-server mysql]# SET PASSWORD FOR dxwang@localhost=OLD_PASSWORD('lhcdlhcd');
bash: syntax error near unexpected token `('
[root@lhcd-server mysql]#



再请问一下,为什么我在kdevelop里写访问数据库的程序都很正常,插入,删除,查询都没有遇到认证协议的问题呢.
到qt里面就有了这个问题呢. 我没有更新server端. 一直用的都是xampp自带的那个mysql.客户端libmysqlclient也是mysql自带的. 这是怎么回事呢.
是不是qmysql3驱动程序的什么问题呢. 用的是linux as3 自带的驱动.

能不能解释一下mysql 客户端和服务器端,我不太明白.
还有为什么kdevelop可以找到正确路径的mysql.sock, 也没有什么 client老的问题.  到 qt designer里面就有这两个问题了? 我都设置了正确的lib和include
  
  
下面是我本机的一些情况: 怎么看到底运行是那个版本?是3.23.58还是4,3,2版本的呢
用mysql -u root password ...命令显示的是3.23.58这个版本.问一下这个是指服务器版本还是客户端版本. 呵呵,我是莱鸟.谢谢赐教!!

[root@lhcd-server root]# rpm -q mysql
mysql-3.23.58-1
[root@lhcd-server root]# rpm -qa |grep mysql
mysql-devel-3.23.58-1
php-mysql-4.3.2-8.ent
mysql-3.23.58-1
mod_auth_mysql-20030510-1.ent
libdbi-dbd-mysql-0.6.5-5
mysql-bench-3.23.58-1
[root@lhcd-server root]#

还有在kdevelop里面没有问题,会不会用的是4,3,2-8这个版本,而在qt designer里面用的是3.23.58这个版本,所以才会在kdevelop里面没问题.到qt designer里面就出现了问题

再次感谢!

[ 本帖最后由 dxwang 于 2005-11-17 10:38 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2005-11-17 10:21 |只看该作者
下面是我本机的一些情况: 怎么看到底运行是那个版本?是3.23.58还是4,3,2版本的呢
用mysql -u root password ...命令显示的是3.23.58这个版本.问一下这个是指服务器版本还是客户端版本. 呵呵,我是莱鸟.谢谢赐教!!

[root@lhcd-server root]# rpm -q mysql
mysql-3.23.58-1
[root@lhcd-server root]# rpm -qa |grep mysql
mysql-devel-3.23.58-1
php-mysql-4.3.2-8.ent
mysql-3.23.58-1
mod_auth_mysql-20030510-1.ent
libdbi-dbd-mysql-0.6.5-5
mysql-bench-3.23.58-1
[root@lhcd-server root]#

还有在kdevelop里面没有问题,会不会用的是4,3,2-8这个版本,而在qt designer里面用的是3.23.58这个版本,所以才会在kdevelop里面没问题.到qt designer里面就出现了问题

再次感谢!

[ 本帖最后由 dxwang 于 2005-11-17 10:23 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2005-11-17 17:38 |只看该作者
rardge
骑士

帮帮忙啊.呵呵

论坛徽章:
0
7 [报告]
发表于 2005-11-18 20:05 |只看该作者
谁知道啊,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP