Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Show Databases

  1. #1
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35

    Unanswered: Show Databases

    I am on my MacBook and using MAMP.

    If I go into phpMyAdmin (part of the MAMP install) and type "SHOW DATABASES" I see several databases:

    - crashcourse (0)
    - forum (4)
    - information_schema (17)
    - myblog (1)
    - mydb (0)
    - mysql (17)
    - sitename (1)
    - test (0)


    If I go launch the app "mysql" and type "SHOW DATABASES" I only see:

    information_schema
    test

    Why the discrepancy??

    The path where the databases seem to be stored is:

    Macintosh HD > Applications > MAMP > db > mysql



    TomTees
    Helping my wife to start an online business selling T-Shirts.

  2. #2
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Could there be an issue with security roles/rights?

    Does the "view" I'm seeing in mysql maybe not have the proper rights to see everything create in phpMyAdmin? (I think MAMP logs you in as "root" in phpMyAdmin...)


    TomTees
    Helping my wife to start an online business selling T-Shirts.

  3. #3
    Join Date
    Mar 2004
    Posts
    480
    the root user is default for phpmyadmin and the mysql client. if logged into both as root you would see the same thing. if you are logged into the client as another user you would only see the databases you have been granted permissions on.

  4. #4
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Quote Originally Posted by guelphdad View Post
    the root user is default for phpmyadmin and the mysql client. if logged into both as root you would see the same thing. if you are logged into the client as another user you would only see the databases you have been granted permissions on.
    Apparently root isn't the default user for the mysql app because I spent quite some time this weekend figuring out what you just said.

    It turns out I had to go to the command line prompt and while telling Terminal to open up mysql, to include the switches that allow you to log in as root.

    This is what I typed in the Terminal window...

    /Applications/MAMP/Library/bin/mysql -u root -p;

    When I typed -u root -p; at the mysql> prompt it wasn't working?!

    (There should be a way to log in as another user at the mysql> prompt!)

    Now that I'm logged in as root, I can indeed see the same tables as phpMyAdmin lists.



    TomTees
    Helping my wife to start an online business selling T-Shirts.

  5. #5
    Join Date
    Mar 2004
    Posts
    480
    you can log in as ANY user you have defined the same way as you have done with the root user above.

  6. #6
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Quote Originally Posted by guelphdad View Post
    you can log in as ANY user you have defined the same way as you have done with the root user above.
    Not when I tried...

    Code:
    mysql> -u root -p;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-u root -p' at line 1
    mysql>

    TomTees
    Helping my wife to start an online business selling T-Shirts.

  7. #7
    Join Date
    Mar 2004
    Posts
    480
    well you can't run that from the mysql prompt, you use that when you log in from your shell.

  8. #8
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Quote Originally Posted by guelphdad View Post
    well you can't run that from the mysql prompt, you use that when you log in from your shell.
    So are you gonna tell me how to switch users and log in as "root" from the mysql> prompt, or do I have to beg??



    TomTees
    Helping my wife to start an online business selling T-Shirts.

  9. #9
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by TomTees View Post
    So are you gonna tell me how to switch users and log in as "root" from the mysql> prompt, or do I have to beg??
    No.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  10. #10
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Now that I got that opportunity addressed...

    You can't get there from here. Once you've logged in from the shell your user is set. The only way to change it is to log in from the shell again.

    Once you build a connection to MySQL using any tool I can think of, your user is set. If you need to use more than one MySQL user from a PHP script, then you open more than one MySQL connection to do that.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  11. #11
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Quote Originally Posted by Pat Phelan View Post
    Now that I got that opportunity addressed...

    You can't get there from here. Once you've logged in from the shell your user is set. The only way to change it is to log in from the shell again.

    Once you build a connection to MySQL using any tool I can think of, your user is set. If you need to use more than one MySQL user from a PHP script, then you open more than one MySQL connection to do that.

    -PatP
    Okay, but that doesn't address my original question...

    Apparently mysql doesn't log you in as root like phpMyAdmin does.

    I have a shortcut to launch the mysql app and it would be nice to just be logged in as root from there as opposed to have to type in some horribly long string including the path and user and password.

    There MUST BE an easier way?!

    If not, then screw command-line and I'm going back to phpMyAdmin.

    (I just figured it would help me to get comfortable using a raw command-line approach to help keep me honest and focus more on learning SQL and MySQL related commands and less on some GUI that helps you cheat and thus learn less?!)



    TomTees
    Helping my wife to start an online business selling T-Shirts.

  12. #12
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Write a batch file to invoke with desired parameters, then put the batch file in a folder that is in your PATH ?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  13. #13
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Wait a second, brain fart there... I work in a Windoze environment, and most new users work there too.

    In the Mac / Linux environment there are more options, but the concept is the same... Just put the command(s) into a file, flag that file as executable using chmod, and make sure that the file is somewhere that your preferred shell will find it.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  14. #14
    Join Date
    Mar 2004
    Posts
    480
    on phpmyadmin you can use the SQL tab to execute any command you want so you won't just point and click.

    Here's a question for you since you seem to be a relatively new user, did you create a password for root and change that setting in phpmyadmin? By default there is no password set for the root user and your system would be completely open to hackers.

    Obviously not directly related to the problems that you are having, but wanted to point that out to you since you may not be aware of that.

  15. #15
    Join Date
    May 2010
    Location
    Iowa
    Posts
    35
    Quote Originally Posted by guelphdad View Post
    on phpmyadmin you can use the SQL tab to execute any command you want so you won't just point and click.
    Is there any learning benefit of using mysql command line over a GUI like phpMyAdmin?


    Here's a question for you since you seem to be a relatively new user, did you create a password for root and change that setting in phpmyadmin? By default there is no password set for the root user and your system would be completely open to hackers.

    Obviously not directly related to the problems that you are having, but wanted to point that out to you since you may not be aware of that.
    I think MAMP set up MySQL and phpMyAdmin with user=root and password=root

    Since I am just working locally, I guess I figured there was no security risk?!


    TomTees
    Helping my wife to start an online business selling T-Shirts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •