Skip page navigation
The University of Edinburgh
Information Services Information Services logo

Creating a table with the mysql command line tool

Log in to holyrood and run the command mysql.

If the command fails because of 'command not found' then try using /usr/local/bin/mysql instead

Replace ercc14_dbo with your 'Owner' username and password with the password you were given. The last parameter is the name of your database.

 

holyrood$ mysql -h morse.ucs.ed.ac.uk -u ercc14_dbo -p ercc14
Enter password: password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 76203 to server version: 3.23.56-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select database();
+------------+
| database() |
+------------+
| ercc14     |
+------------+
1 row in set (0.00 sec)

mysql> show tables;
Empty set (0.00 sec)

mysql> create table testing ( word varchar(20) );
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+------------------+
| Tables_in_ercc14 |
+------------------+
| testing          |
+------------------+
1 row in set (0.01 sec)

mysql> describe testing;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| word  | varchar(20) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)

mysql> insert into testing
            values ('test1'), ('test2');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from testing;
+-------+
| word  |
+-------+
| test1 |
| test2 |
+-------+
2 rows in set (0.00 sec)

mysql> exit
Bye

You have now created a table and put some content in it. The next thing to do is to see if you can read it back from your website.

Last modified: 2006-04-05 10:35:04 BST