Using MySQL

From ULYSSIS documentation
Revision as of 16:20, 28 August 2019 by Bert (talk | contribs)

Creating a MySQL user

To use MySQL on your ULYSSIS account you first need to create a MySQL user on UCC. In the MySQL section of the panel you will be suggested to click a link to create a user. Then fill in a password for the database user. It is highly recommended that this password differs from the password you use for your account. Then you just click Create user and you are ready to go.

Creating a MySQL database

After creating a MySQL user, you can simple press Add database in UCC and enter the name for your new database. It will automatically be prefixed by your username.

Using MySQL for your website or application

Host: mysql.ulyssis.org
Username: your account's username
Password: the password you chose when you made the MySQL user
Database: the database name you chose, prefixed by your username

For example, if my username is foobar, I made a database called website and I were to create a PHP website I would use something like:

$db = new mysqli('mysql.ulyssis.org', 'foobar', 'correct horse battery staple', 'foobar_website');

or

$db = new PDO('mysql:host=mysql.ulyssis.org;dbname=foobar_website', 'foobar', 'correct horse battery staple');

Managing MySQL with PHPMyAdmin

Using your username and password you can easily manage your MySQL databases, tables and records on https://phpmyadmin.ulyssis.org

Accessing MySQL from outside of our network

To prevent unnecessary load on our database server by hackers and bots it is only available inside of our network. If you wish to access it externally the easiest way is to use an SSH-tunnel. In many MySQL management tools this is already supported.

MySQL Workbench

While MySQL Workbench might not fully support our MySQL database, all commonly used operations work perfectly. You can connect to our database using MySQL Workbench by creating a connection as follows ([username] should be replaced by your username, of course): MySQL Workbench SSH.png

Linux, Mac OSX

On Linux, Mac OSX and other Unix-like Operating Systems it is also easily possible to use the following command to create a tunnel to a local port (in this case 3300)

ssh username@ssh2.ulyssis.org -L 3300:mysql.ulyssis.org:3306 -N

While this command is running, you can connect to the MySQL server with host 'localhost' and port '3300'. To terminate the port forwarding, press ctrl-C in the terminal.

You can use "ssh -f username@ssh2.ulyssis.org -L 3300:mysql.ulyssis.org:3306 -N": the f-argument will put the command in the background.