<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paulmheider</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paulmheider"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Paulmheider"/>
	<updated>2026-11-15T22:08:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=3301</id>
		<title>Washington University</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=3301"/>
		<updated>2024-10-24T15:29:47Z</updated>

		<summary type="html">&lt;p&gt;Paulmheider: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Washington University&lt;/div&gt;</summary>
		<author><name>Paulmheider</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=3213</id>
		<title>Washington University</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=3213"/>
		<updated>2024-10-12T18:17:48Z</updated>

		<summary type="html">&lt;p&gt;Paulmheider: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Washington University.&lt;/div&gt;</summary>
		<author><name>Paulmheider</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=2998</id>
		<title>Washington University</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Washington_University&amp;diff=2998"/>
		<updated>2024-09-24T17:09:25Z</updated>

		<summary type="html">&lt;p&gt;Paulmheider: Created page with &amp;quot;Washington University&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Washington University&lt;/div&gt;</summary>
		<author><name>Paulmheider</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Databases_and_MySQL&amp;diff=36</id>
		<title>Databases and MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Databases_and_MySQL&amp;diff=36"/>
		<updated>2009-08-11T19:27:20Z</updated>

		<summary type="html">&lt;p&gt;Paulmheider: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SQL With MySQL=&lt;br /&gt;
&lt;br /&gt;
SQL (Structured Query Language) is a language used to access the database files.  While SQL is the basis for database communication,  database vendors usually add their own small modifications. In order to use SQL, you need to use a client that communicates with the server. Some high-level languages have the libraries for that purpose. Alternatively, you can use ''mysql'' to communicate with the server.&lt;br /&gt;
&lt;br /&gt;
=Installing MySQL=&lt;br /&gt;
&lt;br /&gt;
We will need both mysql server and mysql client. You can install both packages:&lt;br /&gt;
 apt-get install mysql-server mysql-client &lt;br /&gt;
&lt;br /&gt;
When the server is being installed, debian will ask you the root password for the server. Don't leave it empty and pick a ''root'' password. You will need this password when you access your database server to administrate it. If you setup a password and forget it, you can reset it later with some extra work.&lt;br /&gt;
&lt;br /&gt;
Debian repesitories contain several tools that help you  manage MySQL databases easily.  A very powerful MySQL administration tool is PhpMyAdmin that is accessed over the web. You can install it with&lt;br /&gt;
 apt-get install phpmyadmin&lt;br /&gt;
&lt;br /&gt;
And then, add this line to the end of your /etc/apache2/apache2.conf:&lt;br /&gt;
 Include /etc/phpmyadmin/apache.conf&lt;br /&gt;
=Using MySQL=&lt;br /&gt;
==Starting MySQL==&lt;br /&gt;
&lt;br /&gt;
The interface to mysql is ''mysql'' command.  This command invoked typically with the following format&lt;br /&gt;
 mysql -u USERNAME -pPASSORD -hHOST databasename&lt;br /&gt;
&lt;br /&gt;
Note that, the user needs to have access to the database otherwise, MySQL will prompt an error.  See the next section to learn how to give users access to databases&lt;br /&gt;
&lt;br /&gt;
==Managing Users==&lt;br /&gt;
The users in a MySQL database are stored in the &amp;quot;user&amp;quot; table of the &amp;quot;mysql&amp;quot; database. You can add a user by adding a row to the ''user'' table (see SQL commands in later sections). You can access the mysql database at localhost with:&lt;br /&gt;
&lt;br /&gt;
 mysql -u root -pyourpassword mysql&lt;br /&gt;
&lt;br /&gt;
The fields of this table are: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+-----------------------+-----------------------------------+------+-----+---------+-------+&lt;br /&gt;
| Field                 | Type                              | Null | Key | Default | Extra |&lt;br /&gt;
+-----------------------+-----------------------------------+------+-----+---------+-------+&lt;br /&gt;
| Host                  | char(60)                          | NO   | PRI |         |       |&lt;br /&gt;
| User                  | char(16)                          | NO   | PRI |         |       |&lt;br /&gt;
| Password              | char(41)                          | NO   |     |         |       |&lt;br /&gt;
| Select_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Insert_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Update_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Delete_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Create_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Drop_priv             | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Reload_priv           | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Shutdown_priv         | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Process_priv          | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| File_priv             | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Grant_priv            | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| References_priv       | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Index_priv            | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Alter_priv            | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Show_db_priv          | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Super_priv            | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Create_tmp_table_priv | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Lock_tables_priv      | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Execute_priv          | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Repl_slave_priv       | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Repl_client_priv      | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Create_view_priv      | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Show_view_priv        | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Create_routine_priv   | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Alter_routine_priv    | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| Create_user_priv      | enum('N','Y')                     | NO   |     | N       |       |&lt;br /&gt;
| ssl_type              | enum('','ANY','X509','SPECIFIED') | NO   |     |         |       |&lt;br /&gt;
| ssl_cipher            | blob                              | NO   |     |         |       |&lt;br /&gt;
| x509_issuer           | blob                              | NO   |     |         |       |&lt;br /&gt;
| x509_subject          | blob                              | NO   |     |         |       |&lt;br /&gt;
| max_questions         | int(11) unsigned                  | NO   |     | 0       |       |&lt;br /&gt;
| max_updates           | int(11) unsigned                  | NO   |     | 0       |       |&lt;br /&gt;
| max_connections       | int(11) unsigned                  | NO   |     | 0       |       |&lt;br /&gt;
| max_user_connections  | int(11) unsigned                  | NO   |     | 0       |       |&lt;br /&gt;
+-----------------------+-----------------------------------+------+-----+---------+-------+&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Important fields are Host (specifies from which host a user can access the database), User (name of the user), Password (the password for this user), and several boolean  privilege attributes. MySQL provides ''grant'' command that inserts a new row to this table with most of attributes set automatically. The format of ''grant'' is&lt;br /&gt;
 grant PRIVILEGE_NAMES on DATABASE.TABLE to 'USERNAME'@'HOSTNAME' identified by 'USERPASSWORD';&lt;br /&gt;
&lt;br /&gt;
The privileges could be individual privileges, such as SELECT, INSERT, DROP etc., or it could be a group of privileges (USAGE) or it could be ALL privileges. The table name could be a wild card (*), the hostname can be anyhost, or it could contain a wild card '%'. Please note that, if you have multiple client hosts to access this database, you would need to grant permissions for each host.&lt;br /&gt;
&lt;br /&gt;
The following command gives all priviliges to the user ''boss' who has the password ''employer'' if the user connects from the localhost.&lt;br /&gt;
 &lt;br /&gt;
 grant all  on company.* to 'boss'@'localhost' identified by 'employer';&lt;br /&gt;
&lt;br /&gt;
After each grant, you need to tell mysql server to reload grant tables by flushing privileges.&lt;br /&gt;
  flush privileges;&lt;br /&gt;
&lt;br /&gt;
==Managing Databases==&lt;br /&gt;
The databases in mysql are crated with&lt;br /&gt;
 create database DATABASENAME;&lt;br /&gt;
command. You should have administrative rights to be able to do that. A database can be deleted with ''drop'' command:&lt;br /&gt;
 drop database DATABASENAME;&lt;br /&gt;
&lt;br /&gt;
In mysql command prompt, you can change your active database with &lt;br /&gt;
 use DATABASE;&lt;br /&gt;
&lt;br /&gt;
Once the active database is changed, all your command will be applied to the new active database.&lt;br /&gt;
&lt;br /&gt;
For example, the following commands will create and switch to a new database&lt;br /&gt;
 create database company;&lt;br /&gt;
 use company;&lt;br /&gt;
&lt;br /&gt;
==Managing Tables==&lt;br /&gt;
Similar to databases, tables are created and deleted with ''create table'', ''drop table'' command.  When creating a table, the user needs to supply the attribute information.&lt;br /&gt;
&lt;br /&gt;
 create table TABLENAME (ATTRIBUTE TYPE, ATTRIBUTE TYPE,.....);&lt;br /&gt;
&lt;br /&gt;
MySQL contains several attribute types for strings, numerical values, dates etc. The common types include  char, varchar, text, blob, int, float,date etc. MySQL manual contains full list of available types [[http://dev.mysql.com/doc/refman/5.0/en/data-types.html]]&lt;br /&gt;
&lt;br /&gt;
For example, the following command will create a new table called employee&lt;br /&gt;
 create table employee ( name char(20), dept char(20), jobtitle char(20));&lt;br /&gt;
&lt;br /&gt;
You can see the tables in a database with &lt;br /&gt;
 show tables;&lt;br /&gt;
command. You can get a detailed description of a table with:&lt;br /&gt;
 describe TABLENAME;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==SQL Commands==&lt;br /&gt;
===Inserting New Data===&lt;br /&gt;
''insert into'' command inserts a new row to the database&lt;br /&gt;
 insert into TABLENAME values (ATTRIBUTE1_VALUE, ATTRIBUTE2_VALUE,.....)&lt;br /&gt;
If you want to insert a new row with only some attributes set, you can do that by telling which attributes you want to be set:&lt;br /&gt;
 insert into TABLENAME (ATTIBUTE1,ATTRIBUTE2) values (ATTRIBUTE1_VALUE, ATTRIBUTE2_VALUE)&lt;br /&gt;
&lt;br /&gt;
For example, the following commands will insert new employees to the company database.&lt;br /&gt;
&lt;br /&gt;
  insert into employee values (&amp;quot;Alice&amp;quot;,&amp;quot;Wonderland&amp;quot;,&amp;quot;Lost traveler&amp;quot;);&lt;br /&gt;
  insert into employee values (&amp;quot;Peter&amp;quot;,&amp;quot;Neverland&amp;quot;,&amp;quot;Leader&amp;quot;);&lt;br /&gt;
  insert into employee values (&amp;quot;Frodo&amp;quot;,&amp;quot;Shire&amp;quot;,&amp;quot;Ring beerer&amp;quot;);&lt;br /&gt;
===Retrieving Existing Data===&lt;br /&gt;
''select'' command returns the rows from a database where some conditions are matched.&lt;br /&gt;
 select ATTRIBUTE1,ATTRIBUTE2,..... from TABLE [where CONDITION]&lt;br /&gt;
&lt;br /&gt;
Instead of individual attributes, you can ask to receive all row with ''select *''&lt;br /&gt;
&lt;br /&gt;
For example &lt;br /&gt;
 select * from employee;&lt;br /&gt;
will return&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
+-------+------------+---------------+&lt;br /&gt;
| name  | dept       | jobtitle      |&lt;br /&gt;
+-------+------------+---------------+&lt;br /&gt;
| Alice | Wonderland | Lost traveler |&lt;br /&gt;
| Peter | Neverland  | Leader        |&lt;br /&gt;
| Frodo | Shire      | Ring beerer   |&lt;br /&gt;
+-------+------------+---------------+&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or you can get  Peter's title.&lt;br /&gt;
 select `jobtitle` from employee where `name` like 'Peter';&lt;br /&gt;
&lt;br /&gt;
===Updating Existing Data===&lt;br /&gt;
''update'' command is used to update individual rows. The format is&lt;br /&gt;
 update TABLENAME set ATTRIBUTE1=value1,ATTRIBUTE2=value2 .... [where conditions]&lt;br /&gt;
&lt;br /&gt;
For example, the following will update Frodo's job title.&lt;br /&gt;
&lt;br /&gt;
 update employee set `jobtitle`='Hero' where `name` like 'Frodo'&lt;br /&gt;
&lt;br /&gt;
===Deleting Existing Data===&lt;br /&gt;
''delete from'' command is used to delete row(s) from the database&lt;br /&gt;
 delete from employee where CONDITION;&lt;br /&gt;
&lt;br /&gt;
For example, the following command will delete Frodo.&lt;br /&gt;
&lt;br /&gt;
 delete from employee where `name` like 'Frodo';&lt;br /&gt;
where as&lt;br /&gt;
 delete from  employee;&lt;br /&gt;
deletes everything from the table.&lt;br /&gt;
&lt;br /&gt;
=PHP and MySQL=&lt;br /&gt;
&lt;br /&gt;
In order to use mysql function in php, you need to install ''php5-mysql'' package first. Then from a PHP page, you can connect to a mysql database by using ''mysql_connect'' command.&lt;br /&gt;
&lt;br /&gt;
 $link=mysql_connect('HOSTNAME','DATABASEUSER','PASSWORD');&lt;br /&gt;
&lt;br /&gt;
The hostname is either IP or name of the server running MySQL daemon, the database user is the name of the user who can run the required commands and password is the user's the user's password. ''mysql_connect'' returns a mysql object that you will use later to communicate with the server. If the connection fails, $link will be NULL. Once connected, you can select a database:&lt;br /&gt;
 mysql_select_db('DATABASENAME',[$link]);&lt;br /&gt;
If $link is not specified, mysql_select_db tries to find an open connection.&lt;br /&gt;
&lt;br /&gt;
You can close a connection with mysql_close&lt;br /&gt;
 mysql_close($link);&lt;br /&gt;
&lt;br /&gt;
SQL commands are send through ''mysql_query'' command. &lt;br /&gt;
&lt;br /&gt;
 mysql_query(SQLQUERY) &lt;br /&gt;
&lt;br /&gt;
for example,&lt;br /&gt;
 mysql_query(&amp;quot;insert into employee values ('Sheridan','B5','Commander')&amp;quot;) or die('Error, insert query failed');&lt;br /&gt;
&lt;br /&gt;
will insert data to employee table. ''mysql_query'' also receive the data from the server. For example, if you have send a ''select'' query, then you can loop over the results for each returned row.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
  $result = mysql_query('select * from employee');&lt;br /&gt;
&lt;br /&gt;
  while($row = mysql_fetch_array($result, MYSQL_ASSOC))&lt;br /&gt;
  {&lt;br /&gt;
    echo &amp;quot;Name :{$row['name']} &amp;lt;br&amp;gt;&amp;quot; .&lt;br /&gt;
         &amp;quot;Department : {$row['dept']} &amp;lt;br&amp;gt;&amp;quot; .&lt;br /&gt;
         &amp;quot;Job Title : {$row['jobtitle']} &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the sql command is sent, the individual rows are fetched with ''mysql_fetch_array''. The parameter ''MYSQL_ASSOC'' tells the function that the results should be in the format of an associative array, i.e., the attributes can be reached by their names. If you want a numeric array, you can use MYSQL_NUM. The default is MYSQL_BOTH, hence you can avoid specifying this parameter. If you are interested in the number of rows returned, you can call ''mysql_num_rows'' function.&lt;br /&gt;
&lt;br /&gt;
PHP Manual has a very detailed description of each mysql related function [http://us2.php.net/manual/en/ref.mysql.php]&lt;br /&gt;
&lt;br /&gt;
=Other MySQL Information=&lt;br /&gt;
&lt;br /&gt;
The configuration file for MySQL is  ''/etc/mysql/my.cnf''. It specifies MySQL directories and other parameters. If you want to migrate MySQL, it is sufficient to copy files from ''datadir'', which is in debian located at ''/var/lib/mysql''. One interesting parameter is bind-address. By default, it restricts the database access to the localhost, so you may want to comment it out.&lt;br /&gt;
&lt;br /&gt;
The program ''mysqladmin'' is the official program to communicate with the server for managerial tasks. Common tasks that can be handled by ''mysqladmin'' include flushing some MySQL elements (such as tables, privileges etc.), kill mysql threads, restart, shutdown, or validate a client. In order to use this command, you need to provide the administrator password.&lt;/div&gt;</summary>
		<author><name>Paulmheider</name></author>
		
	</entry>
</feed>