unixODBC安装(mysql Ubuntu)
这几天真是郁闷死了,基本每天都在编译安装QT和unixODBC,无奈总会出现些莫名其妙的错误。首先,我承认我Linux玩地不熟,但这些开源软件产商之间的兼容性也太差了吧。所以还是制定个标准比较好,大家都遵守一个约定。从这个意义来说,微软的垄断,还是有一定
这几天真是郁闷死了,基本每天都在编译安装QT和unixODBC,无奈总会出现些莫名其妙的错误。首先,我承认我Linux玩地不熟,但这些开源软件产商之间的兼容性也太差了吧。所以还是制定个标准比较好,大家都遵守一个约定。从这个意义来说,微软的垄断,还是有一定的好处的。最终QT还是没有安装成功,此前有一个版本,经过小的改动已经能编译安装成功了,不知为什么,后来怎么也安装不上,晕阿。后来发现,安装unixODBC可以不启用QT功能,虽然没有图形界面,但核心功能是有的。况且,这个驱动管理器最终还要移植到一个嵌入式操作系统上,相互依赖的组件越多,组件也越难移植。下个星期把unixODBC移植到VxWorks上,估计问题不少......
结合网络上下载的一些资料,把最近工作的的东西总结下。
1.安装unixODBC组件:
(1).在ubuntu下,利用新立德下载命令,很容易就能安装unixODBC
apt-get install unixODBC
(2)利用源码,编译安装(我用的版本是unixODBC-2.2.14)
# tar vxzf unixODBC-2.2.14.tar.gz
# cd unixODBC-2.2.14
# ./configure --enable-gui=no (不利用qt画界面,添加--enable-gui=no)
# make
# make install
通过上面介绍的两种方法,就把unixODBC组件安装成功了。
2.测试unixODBC组件是否能用,即是否能通过数据源访问数据库。
(1)安装mysql,同样可以利用新立德下载管理工具。
apt-get install mysql-server mysql-client
(2)注意:安装mysql后,并没有安装mysql的odbc驱动,因此,还需下载对应的驱动
apt-get install libmyodbc
(3)写配置文件,建立自己的数据源
UNIXODBC的配置文件主要是usr/local/etc/odbcinst.ini以及usr/local/etc/odbc.ini。前者用于配置驱动程序,后者用于保存系统DSN。刚才安装了MySQL的驱动程序,需要把它的配置信息填写到/etc/odbcinst.ini内。现在打开你所喜爱的编辑器,编辑/etc/odbcinst.ini:
[MySQL] <br>Description = MySQL <br>driver for Linux Driver = /usr/lib/odbc/libmyodbc.so <br>Setup = /usr/lib/odbc/libodbcmyS.so <br>FileUsage = 1
配置信息依次是驱动程序描述、驱动程序位置、配置程序位置、驱动程序使用次数。实际的驱动程序位置依Linux发行版的不同而有所差异。 Ubuntu通常位于/usr/lib/odbc/下。Suse位于/usr/lib/unixODBC/。RedHat等发行版可能有所不同。
然后是配置DSN,接下来我们创建一个名为HustMysqlDB的DSN。编辑usr/local/etc/odbc.ini文件
[HustMysqlDB] <br>Description = The Database for HustMysql<br>Trace = On <br>TraceFile = stderr<br>Driver = MySQL <br>SERVER = localhost <br>USER = root <br>PASSWORD = mypassword <br>PORT = 3306 <br>DATABASE = HustMysql<br>
(4)测试DSN
$ isql HustMysqlDB -v
+---------------------------------------+ <br>| Connected! | <br>| | <br>| sql-statement | <br>| help [tablename] | <br>| quit | <br>| | +---------------------------------------+<br>注:-v参数是为了显示调试信息,便于出错时,显示信息方便调试。<br> <br>另外,贴一点关于mysql的常用命令。<br>1.启动mysql:mysqld_safe &<br>2.停止mysql:mysqladmin -uroot -ppassw0rd shutdown 注意,u,p后没有空格<span><br></span>3. 设置mysql自启动:把启动命令加入/etc/rc.local文件中<span><br></span>4. 允许root远程登陆:
1)本机登陆mysql:mysql -u root -p (-p一定要有);改变数据库:use mysql;
2)从所有主机:grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;
3)从指定主机:grant all privileges on *.* to root@"192.168.11.205" identified by "passw0rd" with grant option; flush privileges;
4) 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
5. 创建数据库,创建user:
1) 建库:create database test1;
2) 建用户,赋权:grant all privileges on test1.* to user_test@"%" identified by "passw0rd" with grant option;
3)删除数据库:drop database test1;
6. 删除权限:
1) revoke all privileges on test1.* from test1@"%";
2) use mysql;
3) delete from user where user="root" and host="%";
4) flush privileges;
8. 显示所有的数据库:show databases; 显示库中所有的表:show tables;
9. 远程登录mysql:mysql -h ip -u user -p

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

For many users, hacking an Android TV box sounds daunting. However, developer Murray R. Van Luyn faced the challenge of looking for suitable alternatives to the Raspberry Pi during the Broadcom chip shortage. His collaborative efforts with the Armbia

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.
