Personal tools
User menu

Knowledge Base/Databases/MySQL

From Thalesians

Jump to: navigation, search

Contents

Managing MySQL server

On *nix, enter

mysql -p

and specify the MySQL root password.

You will then see the

mysql>

prompt. You are now ready to issue commands.

Listing databases

mysql> show databases;

will display something like

+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| test                |
| thalesians          |
+---------------------+
4 rows in set (0.00 sec)

Creating a database

Suppose we want to create a database named thalesians_blogs. We do the following:

mysql> create database thalesians_blogs;

Then we should see something like

Query OK, 1 row affected (0.14 sec)

Finally, in order to verify the creation of our new database,

mysql> show databases;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| test                |
| thalesians          |
| thalesians_blogs    |
+---------------------+
5 rows in set (0.00 sec)

Listing users

To list the users and check if they have passwords:

select Host, User, Password from mysql.user;

You should see something like

+-----------+------------------+------------------+
| Host      | User             | Password         |
+-----------+------------------+------------------+
| %         | thalesians_wiki  | 7f5787g48938c6j0 |
| %         | thalesians_time  | 90aa741b39109jk1 |
| %         | root             | 39djk2189edjk380 |
+-----------+------------------+------------------+
3 rows in set (0.00 sec)

Creating a user

mysql> create user 'thalesians_blogs'@'%' identified by 'somepassword';
Query OK, 0 rows affected (0.11 sec)
mysql> grant all on thalesians_blogs.* to 'thalesians_blogs'@'%';
Query OK, 0 rows affected (0.01 sec)
  • This page was last modified on 2 August 2009, at 18:35.
  • This page has been accessed 6,383 times.