next up previous contents index
Next: Databases, tables, and tuples Up: MySQL Server Previous: MySQL Server   Contents   Index

Setting up mysqld

In order to start MySQL all you have to do is start the server:

bash# /etc/rc.d/init.d/mysqld start

When the server is running you will probably want to create the symbolic links so that MySQL server starts up every time that the computer reboots. To do this type:

bash# chkconfig mysqld on

Once this is taken care of you can start up a MySQL client called mysql. Type:

bash# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.36

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

mysql>

This will take you to the MySQL prompt where you can start creating databases, tables, and tuples as well adding rights for users. The first thing to do is probably to figure out what is in the MySQL database right now.

mysql> show databases;
+------------+
| Database   |
+------------+
| mysql      |
| test       |
+------------+
2 rows in set (0.08 sec)

These two databases are the default databases. The mysql database holds information about the users and their passwords. To see this database you must first use it:

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Now you are in the mysql database. To see the tables you can type:

mysql> show tables;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv    |
| db              |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
6 rows in set (0.00 sec)

You can see all of the users on your machine by typing:

mysql> select Host, User from user;
+----------------------+--------+
| Host                 | User   |
+----------------------+--------+
| localhost            | root   |
+----------------------+--------+
1 rows in set (0.00 sec)

You can add additional users by using the grant command. Here is how you would give Bob whose login is a ``bob'' access to use the test database:

mysql> grant all on test.* to bob@localhost;
Query OK, 0 rows affected (0.01 sec)

It says 0 row affected but really a few rows were created in various tables in the mysql database. Once you start to create users they can start to also use mysql. To leave MySQL type:

mysql> exit                                  
Bye

Now Bob could log in by typing the command:

bash$ mysql -h localhost

Ideally you create another account for bob@SERVER where SERVER is your computers hostname. If you do this then Bob can use the computer's hostname as the switch instead of localhost.


next up previous contents index
Next: Databases, tables, and tuples Up: MySQL Server Previous: MySQL Server   Contents   Index
Joseph Colton 2002-09-24