Tuesday, January 18, 2011

Installing MySQL (5.1) on Ubuntu

Install MySQL Server

1. Go to Application > Software Center
2. Search for "mysql".
3. Find "MySQL Server" and install.
4. Give a password for the "root" user when prompted.

Check the installation

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (i686) using readline 6.1 
$ mysqladmin
mysqladmin  Ver 8.42 Distrib 5.1.49, for debian-linux-gnu on i686
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


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

mysql> select version(), current_date;
+-------------------+--------------+
| version()         | current_date |
+-------------------+--------------+
| 5.1.49-1ubuntu8.1 | 2011-01-18   |
+-------------------+--------------+
1 row in set (0.00 sec)


Create a new database and a new user (myself)
mysql> create database testdb;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'socrateos'@'localhost' identified by 'secret';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'socrateos'@'%' identified by 'secret';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to 'socrateos'@'local';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to 'socrateos'@'%';
Query OK, 0 rows affected (0.00 sec)

$ mysql -h localhost -u socrateos -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

mysql> quit
Bye
$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| testdb             |
+--------------------+
3 rows in set (0.00 sec)



6. Documentation fo r5.1 is at: http://dev.mysql.com/doc/refman/5.1/en/index.html

No comments:

Post a Comment