MySQL uses a client-server architecture. You can administer and query a MySQL server through a graphical client such as MySQL Workbench or phpMyAdmin, through command-line tools, or from application code using a database connector.
MySQL Workbench is a desktop GUI for connections, SQL development and administration. A separate PHP/web-server installation is not required merely to use Workbench. Check the current Workbench compatibility notes when connecting to newer MySQL Server releases.
phpMyAdmin is a browser-based administration application written in PHP. It is commonly bundled with local development stacks and hosting control panels. Protect it like any other administrative interface: restrict access, use HTTPS and strong credentials, and avoid exposing an unnecessary public admin endpoint.
The SQL statement is largely independent of the programming language. The connection library and result-handling APIs change.
SELECT id, name, class, mark
FROM student
ORDER BY id;
<?php
$stmt = $dbo->query('SELECT id, name, class, mark FROM student ORDER BY id');
foreach ($stmt as $row) {
echo htmlspecialchars($row['name']) . '<br>';
}
?>
PHP can connect through PDO or MySQLi. The removed original mysql_* extension should not be used in current applications.
import mysql.connector
connection = mysql.connector.connect(
host="localhost",
user="userid",
password="password",
database="database_name",
)
cursor = connection.cursor()
cursor.execute("SELECT id, name, class, mark FROM student ORDER BY id")
for row in cursor:
print(row)
cursor.close()
connection.close()
See the Python/MySQL connection tutorial for connector setup and parameterized queries.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MySqlExample {
public static void main(String[] args) throws Exception {
String url = "jdbc:mysql://localhost:3306/my_tutorial";
try (Connection conn = DriverManager.getConnection(url, "userid", "password");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT name FROM student ORDER BY id")) {
while (rs.next()) {
System.out.println(rs.getString("name"));
}
}
}
}
Current MySQL Connector/J uses the driver class com.mysql.cj.jdbc.Driver when explicit driver loading is needed; the historical com.mysql.jdbc.Driver name should not be copied into new code.
MySQL installation · SQL introduction · SELECT · Tables and records · Excel/Access through ODBC · PHP and MySQL
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.