Subscribe:

Ads 468x60px

Pages

Saturday, June 11, 2011

Installing mysql on Ubuntu

I wanted to install mysql on my Ubuntu os. As a biginner to Ubuntu I found that it's some what difficult thing to do. However I came across my problem after struggling two days with command terminal. I'd like to share my experiences, faults I which have faced during my installation process.
First I found out that I must install mysql-client and mysql-server. So I used (I suggest you to use the root account during this)

sudo apt-get install mysql-client mysql-server

(Note: You must be online when you are doing this)
This will install mysql for you. You just only need to follow the instructins that asked to do. But in my case this wasn't done, I was ended up with an error

Err http://archive.ubuntu.schoolnet.lk/ubuntu/maverick-updates/main mysql-server all 5.1.49-1ubuntu8.1 403 Forbidden

And so on. 


I couldn't understood the exact reason for that but I think my weak network connection might cause for that. Well.., I was not in a mind to give up this. So I went through the link which showed in the error message and I downloaded those files from the archive

(Note: http://archive.ubuntu.schoolnet.lk/ is dedicated ubuntu archive for Sri Lanka. If haven't configured your PC to the nearest ubuntu server at your location, you have to do it first)
After Downloading those missing stuffs I installed those packages using below command

 dpkg -i mysql server_5.1.49-1ubuntu8.1_all.deb
You'll have to answer some questions like password, etc
proceed with the process. After that process you have installed mysql successfully. To check whether it's working or not use:

netstat -tap | grep mysql
If it's working properly you'll see something like this

~$ netstat -tap | grep mysql
tcp        0      0 localhost.localdo:mysql *:*              LISTEN    -              

Finally to run the mysql on command terminal 

mysql -u root -h localhost -p
Then it'll ask for the password. give the password which you have given in the installation process. That's all, now you can see the command terminall turned in to a mysql console.

mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40
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>



To exit from the mysql console:

mysql> exit