CSIM runs a MySQL server that is readily available to our students throughout their study. This server is also backed up every night, offering more reliability than a server that would run on a personal computer.
On this server, there is a database created for your exclusive access and use, the name of this database is your login at CSIM.
This server is accessible only to clients connected inside CSIM network. If you work from outside, you must consider using CSIM VPN.
CSIM is using A-Team MySQL LDAP Authenticator, a third party authentication plugin in MySQL that allow to share LDAP credential with MySQL.
Because of the authentication is proceeded by LDAP, the password must be provided without encryption (clear text password) to MySQL server. Because password are send without encryption, a secure connection (SSL) must be enforced between MySQL client and server.
The information bellow detail how to run clear text password over SSL connection.
Using MySQL command line client
mysql -u <username> -p -h database.csim.cs.ait.ac.th –enable-cleartext-plugin
The option --enable-cleartext-plugin
is required to work with the authentication plugin. This option may have to be compiled when you installed MySQL client; on Ubuntu, this option is part already of the client.
Alternatively, you can chose to set the environment variable LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN
to 1; it will work the same as the option --enable-cleartext-plugin
.
Accessing MySQL from Perl
use DBI;
$ENV{‘LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN’}=1;
my $dbh = DBI->connect(‘DBI:mysql;host=database.csim.cs.ait.ac.th;port=3306;mysql_ssl=1;’,
‘<username>‘, ‘<password>‘, {PrintError => 0});
Note: that we use $ENV{'
to set the environment variable as mentioned above.
Accessing MySQL from PHP with mysqli
PHP has two libraries to access MySQL: mysqli
and PDO
. This is how mysqli
works:$mysqli = mysqli_init();
putenv(“LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1”);
$mysqli->real_connect(‘database.csim.cs.ait.ac.th’, ‘<username>’, ‘<password>‘, NULL, 3306, NULL,
MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
We set the environment variable with putenv
; we also must use real_connect
to be able to use SSL.
Note that the options MYSQLI_CLIENT_SSL
and MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
are required to get SSL to work.
Accessing MySQL from PHP with PDO
putenv(“LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1”);
$options = array(
PDO::MYSQL_ATTR_SSL_CA => true,
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
);
$conn = new PDO(“mysql:host=database.csim.cs.ait.ac.th”, ‘<username>’, ‘<password>’, $options);
The options are required to enable SSL connection. The environment variable is set like above.
Using HeidiSQL to access MySQL
HeidiSQL is a powerful graphical tool to access MySQL and other database servers. There is a page dedicated to the installation and configuration for HeidiSQL.
Accessing MySQL from other languages
I have yet explored other languages, but the examples above may give you valuable hints.