Support » Localhost Installs » same user in PHPMyAdmin for different localhost sites

  • Resolved Lars.Lemming

    (@larslemming)


    I have 4 installations on the same localhost – all with different names (e.g. 1, 2, 3 and 4) and have established the databases for each, however – when for the individual site, I can not use the same username and password (comes up with an error second time I try to saying “‘Lars’@’localhost’ already exist!
    Is there a way that I can have the same username and password on all my WordPress sites – in PhPMyAdmin as well as for the WordPress login for all the sites?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    Are you adding the user or just giving that user permissions in another DB? Those are two different things.

    Lars.Lemming

    (@larslemming)

    I have one site I am working on (1), and need to start on 3 new sites (2, 3 and 4).
    I then place WordPress in each of these folders.
    In htdocs I already have folder 1, and create folder 2, 3 and 4.
    I then change the name of the “wp-config-sample.php” document for each of the new folders/sites, open it, change as follows;
    define(‘DB_NAME’, ‘2’); (and 3 and 4)
    define(‘DB_USER’, ‘Lars’);
    define(‘DB_PASSWORD’, ‘MY-PASSWORD’);
    and leave define(‘DB_HOST’, ‘localhost’); as is.
    I then go in to PhPMyAdmin and create 3 new databases (1 is there already with DB_USER being “Lars” and DB_PASSWORD being “MY-PASSWORD)
    When I try to establish user for site 2, I get the message “‘Lars’@’localhost’ already exist!” (translated from Danish to English).
    So the question is, how can I use the same username and password for all 4 websites, as long as they are on my localhost (it will be changed when I upload to live server)?
    I hope this explains the situation better!

    Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    You can. Don’t create a new user for DBs 2,3, and 4. Just give 'Lars'@'localhost' privs on those databases.

    From the SQL tab:

    GRANT ALL on DB2.* to 'lars'@'localhost'
    GRANT ALL on DB3.* to 'lars'@'localhost'
    GRANT ALL on DB4.* to 'lars'@'localhost'
    Lars.Lemming

    (@larslemming)

    Hmm – Steve Stern, luckily I took a backup of the database for my existing project, as I deleted them all to start over.
    First I created the 4 new databases (byemery, energreen, flexsolution and hjertestarterekabe).
    Then go press the SQL tab to enter – precicely:
    GRANT ALL on byemery.* to ‘Lars’@’localhost’;
    GRANT ALL on energreen.* to ‘Lars’@’localhost’;
    GRANT ALL on flexsolution.* to ‘Lars’@’localhost’;
    GRANT ALL on hjertestarterskabe.* to ‘Lars’@’localhost’;
    (these are the actual titles of the 4 sites I am working on – not 1, 2, 3 and 4)
    Once this is done, I close down the PHPMyAdmin page, open a new webpage and enter:
    http://localhost/byemery
    Here I expect to start setting up the WordPerfect installation – but run into a page which says “Error connecting to the database”!
    Can you see what I do wrong?

    Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    You din’t set a password. The FIRST line should have been

    GRANT ALL on byemery.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘yourpassword’;

    Lars.Lemming

    (@larslemming)

    Hmmmmm – when I do that, I get the following error message:
    Error
    SQL query:

    GRANT ALL on byemery.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘mypassword’
    MySQL said: Documentation

    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘‘mypassword’’ at line 1

    The password ‘mypassword’ is naturally replaced by my actual password, but I do not want to put that out here – you never know 😉

    Any ideas?

    Lars.Lemming

    (@larslemming)

    BTW Steve, thank you for your assistance, help and commitment – and that even on Thanksgiving, happy thanksgiving to you and your nearest

    Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    Did you put a semicolon at the end of the statement?

    Lars.Lemming

    (@larslemming)

    Yes, with the exception of the password, this is EXACTLY the statement I enter:
    GRANT ALL on byemery.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘MyPassword’;
    GRANT ALL on energreen.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘MyPassword’;
    GRANT ALL on flexsolution.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘MyPassword’;
    GRANT ALL on hjertestarterskabe.* to ‘Lars’@’localhost’ IDENTIFIED BY ‘MyPassword’;

    Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    No. The only time you add “identified by” is when you either explicitly create the user or implicitly by giving privs *for the first time*. Once you’ve given a user a password, you don’t do it again.

    Lars.Lemming

    (@larslemming)

    Ahh – Got it, I have now created the user and password for the energreen site manually under the Privileges tab and then in the SQL tab added:
    GRANT ALL on byemery.* to ‘Lars’@’localhost’;
    GRANT ALL on flexsolution.* to ‘Lars’@’localhost’;
    GRANT ALL on hjertestarterskabe.* to ‘Lars’@’localhost’;
    and that seems to work – at least I have not gotten any errors!
    Thank you ever so much Steve Stern for your help

    Lars.Lemming

    (@larslemming)

    Considered solved

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.