MySQL on Fedora 12: Install problems

Discussion in 'Server Operation' started by Riff, Mar 29, 2010.

  1. Riff

    Riff New Member

    Hi everyone

    Apologies if this is in the wrong place, please relocate if necessary.

    I'm very new to Fedora (and Linux generally) and I recently installed F12 using Falco's excellent guide for the Perfect Desktop. I have a very nice day to day machine on this now.

    I'm trying to learn MySQL, and I then followed his guide for a LAMP server located here: http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-fedora-12-lamp

    I installed MySQL and I seem to be able to get it running
    but when I wanted to create a Password using

    I don't get the chance to change the PW and I get this error message:

    connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: NO)'


    Now, I'm a bit of a newbie and I'm struggling to locate the various bits of MySQL around my system etc, but I'll be very grateful for any advice.

    Thanks in Advance!

    Riff
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Does the first or second mysqladmin command give you this error message?
    What's the output of
    Code:
    netstat -tap
    ? What's in /etc/hosts?
     
  3. Riff

    Riff New Member

    The output of netstat in root gives me this:

    the hosts file here:
    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 hellboy
    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 hellboy

    I hope that helps.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Looks ok. Did you set a MySQL root password before?
     
  5. Riff

    Riff New Member

    not to my knowledge. If I did, how could I change it?
     
  6. falko

    falko Super Moderator Howtoforge Staff

  7. carlosinfl

    carlosinfl New Member

    I think I know the issue.

    You should connect to MySQL from your Fedora machine and check some settings before connecting remotely. You should also check and see if Fedora has this file:

    /usr/bin/mysql_secure_installation

    If you have that file noted above, please please please run it. Even if you already installed MySQL, it basically secures your pre-existing install. It helps you set a password for 'root'@'localhost' & asks if you want to allow remote logins for 'root'@'server1.example.com'. Also it removes the 'anonymous' accounts (recommended).

    If you don't have it, no big deal. You can do everything noted above manually via MySQL.

    From your Fedora machine:

    1. Log in as root: mysql -u root -p
    2. Create a super user because using root is not recommended:

    Code:
    mysql> CREATE USER 'riff'@'localhost' IDENTIFIED BY ('password');
    GRANT ALL PRIVILEGES ON *.* TO 'riff'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    
    What you did above was create a new user called 'riff' and then you gave him the same access as root so he can do whatever he needs. Now you don't need to use 'root' anymore. You need to understand that when you create 'riff'@'localhost', this user just like 'root'@'localhost' can only connect to MySQL from the Fedora machine and not remotely. For that you need to create another account 'riff'@'server1.example.com'. Then set a password to that new user and try to connect to MySQL from another server. Make sense?

    Check to make sure you don't already have remote accounts:

    Code:
    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
    mysql> SELECT user, host FROM user;
    +---------+-----------+
    | user    | host      |
    +---------+-----------+
    | carlos  | localhost |
    | natalie | localhost |
    | root    | localhost |
    +---------+-----------+
    3 rows in set (0.00 sec)
    
    As you can see from above I only have accounts that login locally from MySQL server. Not remotely. Now check and make sure you don't have any user accounts w/o a set password:

    Code:
    mysql> SELECT * FROM user WHERE Password="";
    Empty set (0.00 sec)
    
    Post your user and hosts tables like I showed you above so we can see why you can't login remotely. Hope this helped you a little...
     
  8. Riff

    Riff New Member

    Thanks so much for this! I think this is exactly what I need (that said, I've not had a chance to get in and try it out yet)

    I'll keep you posted :)
     
  9. carlosinfl

    carlosinfl New Member

    No problem. Let us know how it works out.
     
  10. Riff

    Riff New Member

    hi there

    ok I've got the file you mention in usr/bin/mysql_secure_installation

    I ran it in terminal and got the following error:

    I tried the login to mysql and got a password request.

    I'm stuck now :D
     
  11. carlosinfl

    carlosinfl New Member

    Well my friend, this is either really fun or going to suck. All depends on your fame of mind. For me it's fun because you learn how to reset your root password which is common for DBA's. You basically have locked yourself out of MySQL and are going to have to perform a password recovery which in my opinion is very easy.

    This is your best bet for "Password recover on MySQL":

    http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html#resetting-permissions-unix
     
  12. Riff

    Riff New Member

    I think it's going to be fun...

    Caveat... I've read the instructions and I'm not sure how comprehensive they are. There are gaps in my knowledge - I'll give it a go and then see where I get but thanks for the link. I was afraid I'd done something like this
    :eek::eek::eek::D
     
  13. Riff

    Riff New Member

    ok I may come across as being pretty stupid here... hope not - but like I said I've got some knowledge gaps. I'm new to MySQL and new to Fedora and especially the command line so bear with me please

    I can start mysql from terminal but not mysqld - so I've done that and search shows I have a mysqld.pid in var/run/mysqld

    I've tried using the kill `cat /mysql-data-directory/host_name.pid` as per the instructions in the link - I've changed it to kill `cat /mysql-data-directory/host_name.pid`
    and I also tried kill `cat /var/run/mysql.pid`

    Nothing seems to happen much and if I try going to the next stage I get an output error saying it can't remove the .pid file.

    I'm probably missing something... any suggestions as to what?

    TIA (again)
     
  14. Riff

    Riff New Member

    ok just an update - I think I've got a working install, though if I'm completely honest, I'm not sure if I know how I managed it.

    Either way, I seem to be able to access MySQL and can start working on learning it properly

    Thanks for the help chaps
     

Share This Page