Link to home
Create AccountLog in
Avatar of Maxwellb
Maxwellb

asked on

What does this MySQL command string mean?

Hi,
I'm trying to install the "Zoneminder" linux secuity camera monitoring software on Fedora Core 8. Part of the installation requriements is that a database is created with the string:
 
mysql -p -u root mysql < /usr/share/zoneminder/db/zm_create.sql > mysqladmin -p -u root reload

The question is what is this doing. What is the name of the database it is creating? What about the username and password? I need to know this because in another part of the instructions it asks for me to input these values into a configuratioin file. Here is the link to the instructions I'm following:
http://www.zoneminder.com/wiki/index.php/Fedora
-and also the main doccumentation-
http://www.zoneminder.com/wiki/index.php/Documentation

Thanks for the assistance!
-Max
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Maxwellb
Maxwellb

ASKER

Hi,

Thanks for the quick response. Just looked at that .sql file - it's pretty bug, so I won't post it here. I did find the name of the database ("zm"), but no reference to a "username" and password. I take it that this command does not create a "mysql" username and password. When I go to 127.0.0.1/zm (the default web path), it gives an error that, "Access is denied for user 'zmuser'@'localhost' (Using password: YES)"

So what do I need to do to create (assuming it is not already created) "zmuser"  with a password that has whatever privileges  it needs on the "zm" database...

Thanks,
-Max
Besides that, the information should be inside the SQL file....or you've created the DB before that command....cannot know

To know about db cration inside the SQL read it and look for
CREATE DATABASE (to know the DB name you are creating)
GRANT  (to know the username and password if they are created inside the SQL file)
mysql -p -u root mysql -e "GRANT ALL PRIVILEGES ON zm.* TO zmuser IDENTIFIED BY 'password'"

change password with the password you want

-e switch make mysql command to call the SQL after connected
>>> I take it that this command does not create a "mysql" username and password.

The command doesn't, but the script might.  You would have to dissect the script to find out.  You can also use SHOW GRANTS to explore what user accounts have been created and what access they have been given.

http://dev.mysql.com/doc/refman/5.1/en/show-grants.html

rigonzale's command to grant privilege to the user should work, but be careful with the host designation.  If this account is to be used only from the localhost, make sure you specify that in the command.  Before running the GRANT command, I would review the current permissions with SHOW GRANTS.  

mysql -p -u root mysql -e "GRANT ALL PRIVILEGES ON zm.* TO zmuser@localhost IDENTIFIED BY 'password'"

You can find the syntax for the GRANT command here:

http://dev.mysql.com/doc/refman/5.1/en/grant.html
I found this in the .sql config file:

grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';

I changed back the original password in the other config file to "zmpass", but I still get the same error when I go to "http://127.0.0.1/zm" And when I try to restart the service, I also get long errors with many references to database errors.

So: Is the problem that I cannot restart the service and therefore it will not re-read the config file I changed the password in to be "zmpass" like in the setup script? Or perhaps the setup script didn't run properly and the database doesn't exist? Is there a way to verify all databse settings are correct? I can still post that .sql file if you think it would be helpful...

Thanks,
Max

mysql -u root -p

when connected to MySQL server

SHOW DATABASES;

Check that zm DB exists

SHOW GRANTS;

Check that user zm exists and have access to zm DB

Then try to connect yourself as zm

from shell

mysql -u zm -p

If no errors appear, try pasting the errors you see when you start the service
This is fairly odd:

[video@localhost ~]$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


I'm quite sure I entered the root password.
root password for the DB or the system?

Mysql does not share authentication with the system....

You need to know root password for mysql to run the script too.....

Let us know if you dont know it, mysql can be started different to recover passwords.....try to....if you mysql server is just installed, without password, that is the default situation....and then change it with

mysqladmin -u root password <new password>
I used just used "su" to get around the above problem...

Here's the result for "SHOW DATABASES;"

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.11 sec)


Well...looks like there's the answer. Unless we're missing something...

Oops, we posted simultaniously. Yes, it is a brand new system - I haven't set a MySQL password.
Ok, run the script again and dont put a password or change the password and use it :)

Basically the script didnt do anything....
So do I need a password to run the original zonminder script properly? Is that why it didn't work?
Didnt work I think cause you've put root password when asked.....but system root password.....mysql didnt have a password so authentication failed....

Do you understand? Basically the script didnt run cause you've put wrong password for mysql
Oops (again) we posted simultaneously. The original command string never requested a password. I simply opened the terminal, pasted it and pressed enter. No error was given, or confirmation.

So... do I run it again without a "-p"? Or do I set up a password?
mysql -p -u root mysql

that is your original command

-p mean ask for password.....

Basically yes, it asked....dont know if you didnt see it, wrote other password.....dont know and doesnt matter

run again the script cause DB zm does not exist

when asked for password put current MYSQL password, dont know if you've changed it or not, if no password, just press enter key
Sorry - what I meant in my last post was that:

mysql -p -u root mysql < /usr/share/zoneminder/db/zm_create.sql > mysqladmin -p -u root reload

never asked for a password...
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ok, NOW it asks me for a password. (Right after I ran "mysql -p -u root mysql < /usr/share/zoneminder/db/zm_create.sql")

Which password is this? Mysql (nonexistent?) or Linux (i.e. root)?


mysql

just press enter if you didnt change mysql password
OK...this is working. Just checked and the zm database is present.
And it works. 127.0.0.1/zm now displays the website.

Thanks!