Results 11 to 20 of 21
I actually tried that before too but am getting the following error...
You have an error in your SQL syntax near '* TO ''@'localhost' IDENTIFIED BY 'some_pass'' at line 1
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-28-2004 #11Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
I Tried
I actually tried that before too but am getting the following error...
You have an error in your SQL syntax near '* TO ''@'localhost' IDENTIFIED BY 'some_pass'' at line 1
been searching around to try to get passed this error but no luck
- 04-28-2004 #12Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
Run this script, and post the output you get please.
Also, which version of MySQL are you using?
Ta,Code:<?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $conn = mysql_connect("localhost", "root", "password") or die(mysql_error($conn)); $lines = explode("\n", $contents); foreach( $lines as $username ) { $query = "GRANT ALL PRIVILEGES ON {$username}.* TO '{$username}'@'localhost' IDENTIFIED BY 'some_pass'"; echo $query . "\n"; mysql_query($query, $conn) or die(mysql_error($conn)); } mysql_close($conn); ?>
Jason
- 04-28-2004 #13Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
This
GRANT ALL PRIVILEGES ON testaccount1.* TO 'testaccount1'@'localhost' IDENTIFIED BY 'some_pass' GRANT ALL PRIVILEGES ON testaccount2.* TO 'testaccount2'@'localhost' IDENTIFIED BY 'some_pass' GRANT ALL PRIVILEGES ON testaccount3.* TO 'testaccount3'@'localhost' IDENTIFIED BY 'some_pass' GRANT ALL PRIVILEGES ON testaccount4.* TO 'testaccount4'@'localhost' IDENTIFIED BY 'some_pass' GRANT ALL PRIVILEGES ON testaccount5.* TO 'testaccount5'@'localhost' IDENTIFIED BY 'some_pass' GRANT ALL PRIVILEGES ON .* TO ''@'localhost' IDENTIFIED BY 'some_pass' You have an error in your SQL syntax near '* TO ''@'localhost' IDENTIFIED BY 'some_pass'' at line 1
Running version 3.23.58-1.0
- 04-28-2004 #14Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
I would guess you have a blank line at the end of your file that is causing you this problem.
This version of the script should take care of it for you:
JasonCode:<?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $conn = mysql_connect("localhost", "root", "password") or die(mysql_error($conn)); $lines = explode("\n", $contents); foreach( $lines as $username ) { //skip username if it is less that 3 chars long... if( strlen($username) < 3 ) continue; $query = "GRANT ALL PRIVILEGES ON {$username}.* TO '{$username}'@'localhost' IDENTIFIED BY 'some_pass'"; echo $query . "\n"; mysql_query($query, $conn) or die(mysql_error($conn)); } mysql_close($conn); ?>
- 04-28-2004 #15Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
Script
Worked perfectly thanks a lot you guys rock!!
- 04-29-2004 #16Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
Permissions
I checked the permissions with that last script that runs without errors but the permissions say None. but with the *.* the permissions get assigned ok.
Thanks
- 04-29-2004 #17Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
Are you connecting to the database as the right user, and from localhost?
eg:
# mysql -h localhost -u username1 -psome_pass username1
Jason
- 04-29-2004 #18Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
Rights
No im not logging in as the user, im using Webmin to check the rights that are assigned to the user. Thanks
- 04-29-2004 #19Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
unless you log in as that user, or you log in as root, you wont be able to access the database.
- 04-29-2004 #20Just Joined!
- Join Date
- Feb 2003
- Posts
- 56
Root
I logged in as root using Webmin to see what permissions are assigned to the accounts that the script created but under the description it says none. But when I run the original script that had *.* the permissions show under the description in webmin?


Reply With Quote
