需注意以下三点:
1、创建数据库的时候:CREATE DATABASE `database`
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';
2、建表的时候 CREATE TABLE `database_user` (
`ID` varchar(40) NOT NULL default '',
`UserID` varchar(40) NOT NULL default '',
......
把mysql.h复制到vc的目录的include目录下
mysql.h在你mysql的安装目录下的include里面如:mysql\include
把libmysql.lib(在mysql的安装目录下,搜索下就能找到)复制到这个目录下(C:\Program Files\Microsoft Visual Studio 9.0\VC\lib),要不连接会出错。
如果编译连接时还是出错。就把libmysql.lib复制到你源程序的目录中
(示例1)、
// TODO: Add your control notification handler code here
char *query;
int t,r;
MYSQL_RES *res;
MYSQL_ROW row;
m_mysql = mysql_init(NULL);
if (!mysql_real_connect(m_mysql,"localhost","databasename",
"yourdatabase-password","yourtable",0,NULL,0))
{
CString errors =mysql_error(m_mysql);
MessageBox(errors,"´íÎó");
}
query="select text from yourtable";
t=mysql_real_query(m_mysql,query,(unsigned int) strlen(query));
if(t)
{
MessageBox(mysql_error(m_mysql));
}
res=mysql_use_result(m_mysql);
row=mysql_fet ......
把mysql.h复制到vc的目录的include目录下
mysql.h在你mysql的安装目录下的include里面如:mysql\include
把libmysql.lib(在mysql的安装目录下,搜索下就能找到)复制到这个目录下(C:\Program Files\Microsoft Visual Studio 9.0\VC\lib),要不连接会出错。
如果编译连接时还是出错。就把libmysql.lib复制到你源程序的目录中
(示例1)、
// TODO: Add your control notification handler code here
char *query;
int t,r;
MYSQL_RES *res;
MYSQL_ROW row;
m_mysql = mysql_init(NULL);
if (!mysql_real_connect(m_mysql,"localhost","databasename",
"yourdatabase-password","yourtable",0,NULL,0))
{
CString errors =mysql_error(m_mysql);
MessageBox(errors,"´íÎó");
}
query="select text from yourtable";
t=mysql_real_query(m_mysql,query,(unsigned int) strlen(query));
if(t)
{
MessageBox(mysql_error(m_mysql));
}
res=mysql_use_result(m_mysql);
row=mysql_fet ......
Each MySQL Cluster host computer running an SQL node must have
installed on it a MySQL binary. For management nodes and data
nodes, it is not necessary to install the MySQL server binary, but
management nodes require the management server daemon
(ndb_mgmd
) and data nodes require the data node
daemon (ndbd
; in MySQL Cluster NDB 7.0 and
later, you can use ndbmtd
instead). It is also
a good idea to install the management client
(ndb_mgm
) on the management server host. This
section covers the steps necessary to install the correct binaries
for each type of Cluster node.
Sun Microsystems, Inc. provides precompiled binaries that support
Cluster. However, we also include information relating to
installing a MySQL Cluster after building MySQL from source. For
setting up a cluster using MySQL's binaries, the first step
in the install ......
For our four-node, four-host MySQL Cluster, it is necessary to
write four configuration files, one per node host.
Each data node or SQL node requires a
my.cnf
file that provides two pieces of
information: a connectstring
that tells
the node where to find the management node, and a line telling
the MySQL server on this host (the machine hosting the data
node) to enable the NDBCLUSTER
storage engine.
For more information on connectstrings, see
Section 3.2.3, “The MySQL Cluster Connectstring”
.
The management node needs a config.ini
file telling it how many replicas to maintain, how much memory
to allocate for data and indexes on each data node, where to
find the data nodes, where to save data to disk on each data
node, and where to find any SQL nodes.
Config ......
Starting the cluster is not very difficult after it has been configured. Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
On the management host, issue the following command from the system shell to start the management node process:
shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Note
ndb_mgmd
must be told where to find its configuration file, using the
-f
or
--config-file
option. (See
Section 4.4, “ndb_mgmd
— The MySQL Cluster Management Server Daemon”
, for details.)
For additional options which can be used with
ndb_mgmd
, seeSection 4.23, “Options Common to MySQL Cluster Programs”
.
On each of the data node hosts, run this command to start the
ndbd
process:
shell> ndbd
If you used RPM files to install My ......
To shut down the cluster, enter the following command in a shell
on the machine hosting the management node:
shell> ndb_mgm -e shutdown
The -e
option here is used to pass a command to
the ndb_mgm
client from the shell. (See
Section 4.23, “Options Common to MySQL Cluster Programs”
, for more
information about this option.) The command causes the
ndb_mgm
, ndb_mgmd
, and any
ndbd
processes to terminate gracefully. Any SQL
nodes can be terminated using mysqladmin
shutdown
and other means.
To restart the cluster, run these commands:
On the management host (192.168.0.10
in our
example setup):
shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini
On each of the data node hosts
(192.168.0.30
and
192.168.0.40
):
shell> ndbd
On the SQL host (192.168.0.20
):
she ......