Appendiks A. Postinstallation af RDBMS

Indholdsfortegnelse
MySQL
MySQL setup under Windows
MySQL setup på OS X på Mac
MySQL setup på Linux
Videre med MySQL uafhængigt af OS
Daily use of MySQL
Installation of Sample Database(s)

MySQL

MySQL setup under Windows

  • Udfør først en global søgning efter mysql.exe. resultatet bliver en streng, hvis indhold ligner: C:\Program files\…\…\bin\mysql.exe. Kopier denne såkaldte søgesti med ctrl-v.
  • Kontrolpanel->System->Avanceret->Miljøvariabler

  • Figur A.1. Opsætning af Windows miljøvariabler
    Opsætning af Windows miljøvariabler

  • Klik på path og vælg Rediger

  • Figur A.2. Ændring af path
    Ændring af path

    Tryk på højre pilfor at komme til slutningen af linjen, der ikke må være markeret med blåt. Tilføj nu et ; (semikolon), og tryk derefter ctrl-v for at indsætte søgeresultatet fra tidligere..

    Fjern teksten mysql.exe fra slutningen af linjen.

    Klik nu på OK eller Gem.


MySQL setup på OS X på Mac

Start en terminal. Under iagttagelse af cAsE, dvs respekt for store og små bogstaver skriv følgende:

find / -type f -name mysql 2>/dev/null

Du skulle nu få et søgeresultat, der kunne ligne: /Applications/…/…/bin/mysql. Kopier denne såkaldte søgesti med cmd-v. Skriv nu følgende i terminalvinduet:

echo 'PATH=$PATH:

tryk cmd-v for at indsætte søgeresultatet fra tidligere. Når det er gjort afsluttes linjen med følgende, idet der trykkes enter efter hver linje:

' >> .bash_profile
echo 'export PATH' >> .bash_profile
source .bash_profile

MySQL setup på Linux

På Linux er mysql placeret i /usr/bin og således allerede på stien. For en gangs skyld er Linux mere brugervenlig end de øvrige ;-)

Videre med MySQL uafhængigt af OS

  • Start MySQL fra et terminalvindue.

    mysql -u root

    When you have the terminal window, signified with a mysql > write as follows to create a user (press enter at the end of each line), replace xxxx with your username, and yyyy with your password. The zzzz being the password you want for the administrator.

    use mysql;
    delete from user where not host = 'localhost';
    grant all privileges on *.* to 'root'@'localhost' identified by 'zzzz' with grant option;
    grant all privileges on *.* to 'xxxx'@'localhost' identified by 'yyyy' with grant option;
    grant all privileges on nobody.* to 'nobody'@'localhost' identified by 'test';
    flush privileges;
    exit;

    You have now created yourself as a privileged database user called xxxx with the password yyyy, and a simple user nobody withe the password test.

    The significance of this is that whoever creates the database, you, has the full set of privileges to the database. Once the database is delegated to use by programs, eg on the web, we want the available access rights to be only as liberal as the situation demands, not more. For this we grant the appropriate rights to nobody impersonated by the programs.

Daily use of MySQL

Normal login
From now on you may use Mysql from the terminal window. When you get the terminal you must write (press enter at the end of each line)
mysql -u xxxx -p
yyyy
Where xxxx is your user-id, and yyyy your password.
Backup database
mysqldump dbdb > backup-file.sql
Where dbdb is the name of your database
Restore database from backup
If database exists, from commandline
mysql dbdb < backup-file.sql
If database does not exist
mysql
create database dbdb;
use dbdb;
\. backup-file.sql
commit;
exit

The database itself is spread over several files, and not for anyone but mysql to administer. The backup-file, however, is perfectly suitable for storing under the auspices of, for example, dropbox.

Installation of Sample Database(s)

Upon installation of the server we need two databases for tests and experiments. They may be downloaded as worldFK.sql, and cms0.sql by right clicking and saving in your personal root dirctory. If you don't know what your personal root is consult your terminal program.

In windows: click Start->write cmd, press enter the terminal prompt reveals your root folder, something like C:\Users\<your name>

In OS X on a Mac: Start terminal, again the prompt tells you something like: /Users/<your name>

Now, start terminal emulation from your root directory, and then invoke mysql as follows (enter at the end of each line):

mysql -u xxxx -p
yyyy

create database cms0;
use cms0;
\. cms0.sql
commit;
select count(*) from page;

create database world;
use world;
\. worldFK.sql
commit;
select count(*) from country;
Figur A.3. Creation of One of the Databases
Creation of One of the Databases

This must be entered immediately before you press enter for the input process to start.


Please notice the commit; immediately after the program reads the data. When that is done you may write the select-sentence.

If you get the answer 239 from the world database, and the answer 5 from the cms0 database everything is fine. Leave the program with

quit
Figur A.4. After the creation
After the creation

The window just before you leave the program:


Quit the terminal window.