Help in clarifying syntax
Help in clarifying syntax
I need help in clarifying what the documentation said.
At the site http://www.zoneminder.com/fileadmin/dow ... EADME.html, it said
For a new installation the simplest way to create your database and users is as follows,
1)
mysql mysql < zmschema.sql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database < zmschema.sql ?
2)
mysql mysql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database
3)
grant select,insert,update,delete on <your database name>.* to '<your first username>'@localhost identified by '<your first password>';
grant select,insert,update,delete on my-database to admin@localhost mypassword
Is the syntax for the command above correct ?
4)
quit
5)
mysqladmin reload
=====================
Are all of the command syntax correct ? Is there any quote needed around
the database name or the user name or the password ?
Thank you for your help.
At the site http://www.zoneminder.com/fileadmin/dow ... EADME.html, it said
For a new installation the simplest way to create your database and users is as follows,
1)
mysql mysql < zmschema.sql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database < zmschema.sql ?
2)
mysql mysql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database
3)
grant select,insert,update,delete on <your database name>.* to '<your first username>'@localhost identified by '<your first password>';
grant select,insert,update,delete on my-database to admin@localhost mypassword
Is the syntax for the command above correct ?
4)
quit
5)
mysqladmin reload
=====================
Are all of the command syntax correct ? Is there any quote needed around
the database name or the user name or the password ?
Thank you for your help.
-
- Posts: 74
- Joined: Wed Feb 25, 2004 5:06 pm
Hi Unclerichy. Thank you for your help. Here is what I did in creating the sql database.
I have problem with step number 1 and that is mysql my-database < zmschema.sql
1)
[root@localhost zm-1.19.1]# mysql my-database
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
2)
[root@localhost zm-1.19.1]# mysql my-database < zmschema.sql
bash: zmschema.sql: No such file or directory
3) Since number 2) from above did not work, I used number 3) as shown below
[root@localhost zm-1.19.1]# mysql my-database < /usr/local/zm-1.19.1/db/zmschema.sql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
Thank you for your help
I have problem with step number 1 and that is mysql my-database < zmschema.sql
1)
[root@localhost zm-1.19.1]# mysql my-database
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
2)
[root@localhost zm-1.19.1]# mysql my-database < zmschema.sql
bash: zmschema.sql: No such file or directory
3) Since number 2) from above did not work, I used number 3) as shown below
[root@localhost zm-1.19.1]# mysql my-database < /usr/local/zm-1.19.1/db/zmschema.sql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
Thank you for your help
-
- Posts: 74
- Joined: Wed Feb 25, 2004 5:06 pm
It looks like you may have set a password to access your mysql database. Try using mysql -p instead of just mysql, or possibly mysql -u your-username -p if you need to log in to you database with a different username 'your-username'. Either way, you should be prompted for a password.
This all assume that your mysql server and your zoneminder install are on the same machine!
Hope this helps![/b]
This all assume that your mysql server and your zoneminder install are on the same machine!
Hope this helps![/b]
Hi Unclerichy. Thank you for your help. Here is what I did in creating the sql database.
I ran the command CREATE DATABASES allusers, but it never create the database allusers
=====================================================
[root@localhost zm-1.19.1]# mysql -u root-p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SHOW DATABASES
-> CREATE DATABASES allusers
-> SHOW DATABASES
-> mysql allusers
-> SHOW DATABASES
->
I ran the command CREATE DATABASES allusers, but it never create the database allusers
=====================================================
[root@localhost zm-1.19.1]# mysql -u root-p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SHOW DATABASES
-> CREATE DATABASES allusers
-> SHOW DATABASES
-> mysql allusers
-> SHOW DATABASES
->
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Hi,
It is not 'create databases' as in your example
In your original questions
Phil,
It is not 'create databases' as in your example
but 'create database'. Also you need to terminate each command with a ';' otherwise it will not be parsed.mysql> SHOW DATABASES
-> CREATE DATABASES allusers
-> SHOW DATABASES
-> mysql allusers
-> SHOW DATABASES
->
In your original questions
In the first example, it can either be mysql mysql or mysql <yourdb>. It doesn't matter as the first line of zmschema.sql tells it to use the ZM database. So use either or neither, just mysql < zmschema.sql will work also. In question (2) it definitely does need to be mysql mysql as this is the system database that contains the permissions tables. In the thrid question1)
mysql mysql < zmschema.sql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database < zmschema.sql ?
2)
mysql mysql
Is the first mysql a command or a name of a database ?
Is the second mysql a command or a name of a database ?
would it be something like mysql my-database
The syntax is correct AFAIK and once you have executed this command and reloaded the permissions tables you will be able to access the database as follows mysql -h localhost -u <your first username> -p <your first password> though you may find you don't need the -h localhost part.3)
grant select,insert,update,delete on <your database name>.* to '<your first username>'@localhost identified by '<your first password>';
grant select,insert,update,delete on my-database to admin@localhost mypassword
Is the syntax for the command above correct ?
Phil,
-
- Posts: 74
- Joined: Wed Feb 25, 2004 5:06 pm
Almost there linh!
A few things to look out for:
1. All SQL commands must be terminated with a ';'. If you miss off the ; then mysql keeps prompting you with a ->
2. SQL commands don't need to be in upper case.
3. The syntax is CREATE DATABASE, not CREATE DATABASES (note the S)
4. Once inside the mysql command line, the command to switch databases is USE.
For reference, here's what happens when I tried it (things I type are in bold)
--------
epia# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 46741 to server version: 4.0.13-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| zm |
+----------+
2 rows in set (0.00 sec)
mysql> create database allusers;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+----------+
| Database |
+----------+
| allusers |
| mysql |
| zm |
+----------+
3 rows in set (0.00 sec)
mysql> use allusers;
Database changed
mysql> quit;
epia#
A few things to look out for:
1. All SQL commands must be terminated with a ';'. If you miss off the ; then mysql keeps prompting you with a ->
2. SQL commands don't need to be in upper case.
3. The syntax is CREATE DATABASE, not CREATE DATABASES (note the S)
4. Once inside the mysql command line, the command to switch databases is USE.
For reference, here's what happens when I tried it (things I type are in bold)
--------
epia# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 46741 to server version: 4.0.13-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| zm |
+----------+
2 rows in set (0.00 sec)
mysql> create database allusers;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+----------+
| Database |
+----------+
| allusers |
| mysql |
| zm |
+----------+
3 rows in set (0.00 sec)
mysql> use allusers;
Database changed
mysql> quit;
epia#
Last edited by unclerichy on Thu Apr 15, 2004 10:22 pm, edited 1 time in total.
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
HI unclerichy. I really appreciate your help. I had been stuck with this problems for two days now. I did create a database.
database name: linh
user name: admin
password:my-pass
mysql> grant select,insert,update,delete on linh to admin@localhost identified by my-pass;
ERROR 1064: You have an error in your SQL syntax near 'my-pass' at line 1
Thank you for your help.
database name: linh
user name: admin
password:my-pass
mysql> grant select,insert,update,delete on linh to admin@localhost identified by my-pass;
ERROR 1064: You have an error in your SQL syntax near 'my-pass' at line 1
Thank you for your help.
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
The command given
grant select,insert,update,delete on <your database name>.* to '<your first username>'@localhost identified by '<your first password>';
does require you to quote your username and password, plus as pointed out above you need to add a .* after your DB name. Check the MySQL documentation for further information.
Phil,
grant select,insert,update,delete on <your database name>.* to '<your first username>'@localhost identified by '<your first password>';
does require you to quote your username and password, plus as pointed out above you need to add a .* after your DB name. Check the MySQL documentation for further information.
Phil,