Friday, May 10, 2013

The Database Manager Formerly Known as MySQL

Oracles are kind of cool. Sure, they aren't around anymore, but in olden times they were known for wise counsel and prophetic visions. Anyone who makes a living by instilling vague truths and rumors onto their audience is okay in my book; however, Oracle, the company, seems to have a knack for plucking fantastic open-source software and closing it off to developers. Anyone who makes a living doing that is not okay in my book. I do not mean to antagonize them, but a few years ago, they took OpenOffice, and now they have MySQL--the cherished Database Manager that everyone knows and loves. Of course, rather than whining about it, the linux community evolved the two projects into LibreOffice and MariaDB, respectively, so no incredible harm was done. 

In the case of MariaDB, the developers decided to keep all of the old commands from MySQL, meaning that practically anything you could do with MySQL, you can do with MariaDB while still believing you are using MySQL. That being said, after installing MariaDB on your system, you might as well find a MySQL guide to follow to  get to your database management utilities (like we did at the end of yesterday's post). Firstly, install MariaDB on your system and start the daemon. In Arch, this can be done  with:

# systemctl start mysqld

In Ubuntu:

# service mysqld start

Afterwards, run the secure installation:

# mysql_secure_installation

This will give you an interractive set-up that is quite easy to follow. Remember that your MariaDB root and local root are different. If I were you, I would assign different passwords to each. If you are ever in doubt of how to answer a question, go with the most secure option. You can always change it later. Once done, you have effectively set up MariaDB and can log in to your MariaDB root account with:

$ mysql -p -u root

Which is all fine and dandy, but how do you access a database from a non root user? Well, the next steps will get you there. First, once you are logged on as root, type in the following command:

# create database databasename;

This, as implied by the script, creates a database with a name "databasename." From here, we will give your local user permission to use that database and set an appropriate password:

# grant usage on *.* to user@localhost identified by 'password';

Now we need to grant all privileges to your local user:

# grant all privileges on databasename.* to user@localhost;

And that's that. You can log on to edit your database with:

$ mysql -u user -p'password' databasename

And now we have set up both Postgresql and MariaDB as database managers. In the posts to come, you can use whichever database manager you wish. Tomorrow, we will work on Python some more before moving to our first web framework, web.py! 

Thanks for reading,
Leios

No comments:

Post a Comment