MySQL Cluster Example with Tables and Data
1542
FLUSH TABLES
on each SQL node in the cluster. This causes the node to
recognize the database and read its table definitions.
Running
SELECT
queries on the SQL node is no different from running them on any other instance of a
MySQL server. To run queries from the command line, you first need to log in to the MySQL Monitor in
the usual way (specify the
root
password at the
Enter password:
prompt):
shell>
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.96
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
We simply use the MySQL server's
root
account and assume that you have followed the standard
security precautions for installing a MySQL server, including setting a strong
root
password. For more
information, see
Section 2.18.2, “Securing the Initial MySQL Accounts”
.
It is worth taking into account that Cluster nodes do not make use of the MySQL privilege system when
accessing one another. Setting or changing MySQL user accounts (including the
root
account) effects
only applications that access the SQL node, not interaction between nodes. See
Section 17.5.10.2,
“MySQL Cluster and MySQL Privileges”
, for more information.
If you did not modify the
ENGINE
clauses in the table definitions prior to importing the SQL script, you
should run the following statements at this point:
mysql>
USE world;
mysql>
ALTER TABLE City ENGINE=NDBCLUSTER;
mysql>
ALTER TABLE Country ENGINE=NDBCLUSTER;
mysql>
ALTER TABLE CountryLanguage ENGINE=NDBCLUSTER;
Selecting a database and running a
SELECT
query against a table in that database is also
accomplished in the usual manner, as is exiting the MySQL Monitor:
mysql>
USE world;
mysql>
SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5;
+-----------+------------+
| Name | Population |
+-----------+------------+
| Bombay | 10500000 |
| Seoul | 9981619 |
| São Paulo | 9968485 |
| Shanghai | 9696300 |
| Jakarta | 9604900 |
+-----------+------------+
5 rows in set (0.34 sec)
mysql>
\q
Bye
shell>
Applications that use MySQL can employ standard APIs to access
NDB
tables. It is important to
remember that your application must access the SQL node, and not the management or data nodes.
This brief example shows how we might execute the
SELECT
statement just shown by using the PHP
5.X
mysqli
extension running on a Web server elsewhere on the network:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>SIMPLE mysqli SELECT</title>
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...