| 1 | |
|---|
| 2 | Use SQL with PennMUSH |
|---|
| 3 | Revised: 24 May 2004 |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | As of version 1.7.7p32, PennMUSH includes functions and commands that |
|---|
| 7 | can access SQL databases. Currently, the following databases are |
|---|
| 8 | supported: |
|---|
| 9 | |
|---|
| 10 | * MySQL |
|---|
| 11 | |
|---|
| 12 | This document explains how to use (or avoid) SQL with PennMUSH, and covers |
|---|
| 13 | the following issues: |
|---|
| 14 | |
|---|
| 15 | I. Compiling with or without SQL |
|---|
| 16 | II. Mush configuration overview |
|---|
| 17 | III. SQL setup tips |
|---|
| 18 | |
|---|
| 19 | I. Compiling withi MySQL |
|---|
| 20 | |
|---|
| 21 | The Configure script distributed with PennMUSH automatically detects |
|---|
| 22 | the MySQL client library (libmysqlclient) and attempts to link |
|---|
| 23 | them into the executable, defining HAS_MYSQL in config.h |
|---|
| 24 | |
|---|
| 25 | If you want to avoid linking these libraries on systems where they |
|---|
| 26 | are present, use the '-D no_mysql' switch to Configure. |
|---|
| 27 | |
|---|
| 28 | If you installed Mysql from a binary package (e.g. rpm or apt), |
|---|
| 29 | you should be sure that your system also has the development |
|---|
| 30 | package (usuallyl mysql-dev or mysql-devel). |
|---|
| 31 | |
|---|
| 32 | If you think you have mysql libraries and header files but Configure |
|---|
| 33 | isn't finding them, they may be in an unusual location on your system. |
|---|
| 34 | Creating symbolic links from the header directory to /usr/include/mysql |
|---|
| 35 | and from the libraries in /usr/lib (or adding the mysql library directory |
|---|
| 36 | to your /etc/ld.so.conf and running ldconfig) are the easiest ways |
|---|
| 37 | to fix this. |
|---|
| 38 | |
|---|
| 39 | II. Mush configuration overview |
|---|
| 40 | |
|---|
| 41 | mush.cnf includes these directives that configure the SQL support: |
|---|
| 42 | |
|---|
| 43 | sql_platform provides the name of the SQL database server software |
|---|
| 44 | that will be used for connections. It current takes one of two |
|---|
| 45 | values: "disabled" (no SQL) or "mysql". If not specified, it |
|---|
| 46 | defaults to disabled. |
|---|
| 47 | |
|---|
| 48 | sql_host gives the name of the host running the SQL server. |
|---|
| 49 | It defaults to 127.0.0.1, which makes a TCP connection to the |
|---|
| 50 | local host. The keyword "localhost" instead makes a domain socket |
|---|
| 51 | (Unix) or named pipe (Windows) connection. |
|---|
| 52 | |
|---|
| 53 | sql_database gives the name of the database that contains the |
|---|
| 54 | MUSH's tables. This must be specified and there is no default. |
|---|
| 55 | |
|---|
| 56 | sql_username provides a username to connect to the SQL server |
|---|
| 57 | with. If no specified, a null username will be used, which many |
|---|
| 58 | SQL servers treat as "the user running this (pennmush) process". |
|---|
| 59 | |
|---|
| 60 | sql_password provides the password for the user. It defaults to |
|---|
| 61 | no password. |
|---|
| 62 | |
|---|
| 63 | III. SQL setup tips |
|---|
| 64 | |
|---|
| 65 | You will have to set up the appropriate database on the SQL server, |
|---|
| 66 | and username permitted to perform operations in that database, |
|---|
| 67 | and a password for that username. This is a platform-specific process. |
|---|
| 68 | |
|---|
| 69 | A. MySQL platform |
|---|
| 70 | |
|---|
| 71 | Easiest way is: |
|---|
| 72 | |
|---|
| 73 | % mysql_setpermission --user root REQUIRED |
|---|
| 74 | --host <mysql host> --port <mysql port> OPTIONAL, OR: |
|---|
| 75 | --socket <unix domain socket> OPTIONAL |
|---|
| 76 | |
|---|
| 77 | ###################################################################### |
|---|
| 78 | ## Welcome to the permission setter 1.2 for MySQL. |
|---|
| 79 | ## made by Luuk de Boer |
|---|
| 80 | ###################################################################### |
|---|
| 81 | What would you like to do: |
|---|
| 82 | 1. Set password for a user. |
|---|
| 83 | 2. Add a database + user privilege for that database. |
|---|
| 84 | - user can do all except all admin functions |
|---|
| 85 | 3. Add user privilege for an existing database. |
|---|
| 86 | - user can do all except all admin functions |
|---|
| 87 | 4. Add user privilege for an existing database. |
|---|
| 88 | - user can do all except all admin functions + no create/drop |
|---|
| 89 | 5. Add user privilege for an existing database. |
|---|
| 90 | - user can do only selects (no update/delete/insert etc.) |
|---|
| 91 | 0. exit this program |
|---|
| 92 | |
|---|
| 93 | Make your choice [1,2,3,4,5,0]: 2 <========== |
|---|
| 94 | |
|---|
| 95 | Which database would you like to add: mush |
|---|
| 96 | The new database mush will be created |
|---|
| 97 | |
|---|
| 98 | What username is to be created: mush <========== |
|---|
| 99 | Username = mush |
|---|
| 100 | Would you like to set a password for [y/n]: y <========== |
|---|
| 101 | What password do you want to specify for : <========== |
|---|
| 102 | Type the password again: <========== |
|---|
| 103 | We now need to know from what host(s) the user will connect. |
|---|
| 104 | Keep in mind that % means 'from any host' ... |
|---|
| 105 | The host please: localhost <========== |
|---|
| 106 | Would you like to add another host [yes/no]: no <========== |
|---|
| 107 | Okay we keep it with this ... |
|---|
| 108 | The following host(s) will be used: localhost. |
|---|
| 109 | ###################################################################### |
|---|
| 110 | |
|---|
| 111 | That was it ... here is an overview of what you gave to me: |
|---|
| 112 | The database name : mush |
|---|
| 113 | The username : mush |
|---|
| 114 | The host(s) : localhost |
|---|
| 115 | ###################################################################### |
|---|
| 116 | |
|---|
| 117 | Are you pretty sure you would like to implement this [yes/no]: yes |
|---|