1】下载安装好mySQL环境

2】FDConnection1的设置

3】执行增删改SQL语句查询Select语句

4】客户端连接


1】下载安装好mySQL环境,注意32位/64位。本篇为32位

mysql32位下载链接: https://pan.baidu.com/s/1hVS_vbBQUAnMakDdlN07ZQ 提取码: wx44

MYSQL新手入门篇https://www.cnblogs.com/winton-nfs/p/11524007.html

用户命令行,修改密码增加DataBase,db1


cd c:mysql-5.7bin
mysqld --install
mysqld --initialize --console//有默认密码,记得保存
net start mysql

mysql -u root -p //输入密码
     alter user 'root'@'localhost' identified by 'root';

     create database db1;

use db1;

 show tables;

create table tb1 (id int);

insert into tb1 values (2);

Path路径系统变量加入c:mysql-5.7bin


 将libmysql.dll拷到C:WindowsSystem32

 确保MySQL服务启动,也可以命令行启动MySQL服务            net start mysql


 2】FDConnection1的设置

 FDConnection1.LoginPrompt: = False;//不提示登录窗口。


 3】执行,增insert,改update ,删除delete 语句SQL语句

procedure TForm3.Button1Click(Sender: TObject);
begin
 FDConnection1.ExecSQL('insert into tb1 values(5);');
  button1.Caption := FDConnection1.ExecSQLScalar('select MAX(id) from tb1');
end;

    3-2】执行select 查询语句,要新加FDQuery1,设置FDQuery1的Connection为FDConnection1

FDQuery1.Open('select * from tb1 where id>5');

4】客户端连接

https://www.cnblogs.com/happyhills/p/3723842.html

1、SQLConnection1: TSQLConnection
ConnectionName = 'MYSQLCONNECTION'
DriverName = 'MySQL'
GetDriverFunc = 'getSQLDriverMYSQL'
LibraryName = 'dbxmys.dll'
LoginPrompt = False
Params.Strings = (
'HostName=localhost'
'Database=mysqldb'
'User_Name=root'
'Password=pswd'
'MaxBlobSize=-1

ServerCharSet=utf8')
VendorLib = 'libmysql.dll'
Connected = True

2、 SQLTable1: TSQLTable
GetMetadata = False
MaxBlobSize = -1
SQLConnection = SQLConnection1
TableName = 'human'


3、DataSource1: TDataSource
DataSet = ClientDataSet1

4、DataSetProvider1: TDataSetProvider
DataSet = SQLTable1

5、ClientDataSet1: TClientDataSet
Active = True
ProviderName = 'DataSetProvider1'


6、DBGrid1: TDBGrid
DataSource = DataSource1

7、 DBNavigator1: TDBNavigator
 DataSource = DataSource1
 

8、Button1: TButton
Caption = 'Button1'
OnClick = Button1Click
需要的控件
procedure TForm1.Button1Click(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates(0);//更新
end;

最后找到两个库文件一同发布就可以了。

LibraryName = 'dbxmys.dll'
VendorLib = 'libmysql.dll'

 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/tulater/p/12986479.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!