Friday, May 22, 2009

In my server webmin was installed but mysql was not there. The server was running centos5.3.

After some googling i found some solutions and here is the combination which might solve your problems.

You have to have access to a shell window in the server. You can access using putty or
by loggin into your webmin, go to Others->Command Shell.You can type commands in this shell.

If using putty, you will get the command shell any way :) after logging in.

Inorder to check if mysql is already installed or not run this command
which mysql
If found it will show some directory name otherwise not found

In order to remove old mysql
yum remove mysql-server
yum remove mysql

Now to install mysql run this command from the shell or a command line access point
yum install mysql-server
yum install mysql
yum install mysql-devel

Inorder to use with php
yum install php-mysql

By default mysql has the no passward. To change the password in command shell write the following commands
mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

That's all, if anything is missing let me know

18 Comments:

  1. Sulman Sarwar said...
    i follow all the steps and mysql is installed successfully but when i do
    $: mysql

    it gives me this error:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    Any idea what is going on??
    Sulman Sarwar said...
    I have figured it out ... its working now.. i had not started the mysql service...which you can start by doing:

    $: service mysqld start

    after you are finished 'yumming' everything.. :D
    Shimul said...
    great to know that things are working for you
    Unknown said...
    I tried yum install mysqul-server
    I get an error as follows
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os error was

    it looks it searchs for internet, but I do not have internet on my server
    PR
    Unknown said...
    Is there any other way to install mysql?
    PR
    Martin said...
    Hi Shimul,

    Thanks, this post worked perfectly for me!

    The only step I'd add is to start the mysql service:

    $ service mysqld start

    And that, the first time you load the mysql client, I used the following command:

    $ /usr/bin/mysql -u root -p

    Then hit enter at the command prompt that asked for a password.

    I then followed your steps to change the root password, logged out, and then back in again.

    Brilliant guide, thank you!
    Tabu said...
    Thanks a ton...!!
    The problem with me was I have not installed mysql-server....heheh
    as I did yum install mysql
    but Now I know I should have done
    yum install
    yum install mysql-server
    yum install mysql-bench
    yum install mysql-devel

    in order to install all the packages...
    Thanks.....
    Tabrez
    Anonymous said...
    Mike,

    Sounds like something got messed up in install. Easy to fix. This goes for windows too, obviously diff syntax for dir's....

    1.) Stop mysql:
    # /etc/init.d/mysql stop

    2.) Start to MySQL server w/o password:
    # mysqld_safe --skip-grant-tables &

    3.) Connect to mysql server using mysql client:
    # mysql -u root

    4.) Setup new MySQL root user password:

    mysql> use mysql;
    mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
    mysql> flush privileges;
    mysql> quit


    5.) Stop MySQL Server:
    # /etc/init.d/mysql stop

    5.) Start MySQL server and test it
    # /etc/init.d/mysql start
    # mysql -u root -p


    Of course this should all be done local host style, like over ssh *putty or whatever. Follow the same steps for Windows *if needed. its actually easier to do, you just stop the service in the service list in XP. Anyway, it sounded like you forgot your password. While I was in there, I may go ahead and create a version of the root user that can connect from any machine too... which looks like this:

    mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

    Its the % that allows mysql admin to allow connections from all machines for that user. Hope its been at least a little helpfull. Anyway. Good luck.
    Ashis said...
    [root@test3 ~]# yum install mysql-server
    Loading "installonlyn" plugin
    Setting up Install Process
    Setting up repositories
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=os error was
    [Errno 4] IOError:
    Error: Cannot find a valid baseurl for repo: base
    Ashis said...
    Hi I have used the following command but this give errors please any one cansuggest abt the some.

    [root@test3 ~]# yum install mysql-server
    Loading "installonlyn" plugin
    Setting up Install Process
    Setting up repositories
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=os error was
    [Errno 4] IOError:
    Error: Cannot find a valid baseurl for repo: base
    GIRISH M SHABADIMATH said...
    i want to install mysql with federated engine
    how to proceed..?
    Unknown said...
    I followed the steps but the problem is after complete installation I can't see the default user database 'mysql' and hence therefore can't assign password to my root user.
    any idea or hint in this regard.
    Nostradamus said...
    I've got


    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)


    After isntalling with yum. please help lol
    Shahryar Ghazi said...
    simple instructions at
    http://www.geeksww.com/tutorials/database_management_systems/mysql/installation/downloading_compiling_and_installing_mysql_server_from_source_code.php
    Anonymous said...
    hi

    can u plz tell me what to do if i want to use mysql with java.
    Unknown said...
    Excellent Post..!!! followed everything inc. starting the server.. and it worked like a charm.. Thanks a ton!!

    Anirban
    Owais... said...
    Dear All,

    There is a very important thing that is missing in this blog, if any of you are facing the following error:

    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os error

    Then go to console and write
    $ yum update
    $ yum install kernel*


    and then proceed as written in the blog.
    Gadelkareem said...

Post a Comment