Jump to content

satimis

Members
  • Posts

    91
  • Joined

  • Last visited

Posts posted by satimis

  1. If you make the table name a variable then you can run the same SQL code over however many tables you want.
    Hi justsomeguy,Whether adding following heading on top
    $table=users, table_name2, table_name3, etc

    changing following line;

    $Q = "SELECT * FROM users"; // select everything

    to;

    $Q = "SELECT * FROM $table"; // select everything

    ???I haven't figured out how to make following items as variable;

    //row for each recordwhile ($row = mysql_fetch_assoc ($result) ) { // loop through the result setecho"<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td><td>" . $row['c$}

    Any advice? Thanks

    SHA1 is built into most languages, it's built into PHP and it's built into MySQL, you don't need a separate package for it. For languages that don't have it built-in, like Javascript, there are several algorithms you can find online to implement it. I don't know what sha1sum is.
    Following PHP script works for me generating SHA1 hash
    <?php$str="apassword";$hash=sha1($str);  print $hash;?>

    I haven't figured a script to be run on variable. Say for example;On terminal$ php -f /path/to/script.php password_1/password_2/password-3 etc.Any advice? TIAEdit:Just discovered;The sha1 hash generated by running "script.php" differed from the encrypted password on MySQL table ?On MySQL table;

    0eWBW8//TnfEg

    On terminal;$ php -f /home/satimis/php_pw.php

    99232baee6cb82c26cdd2fafebac37d9e2020976

    It seems MySQL running different encrypting method ?B.R.satimis

  2. - snip -I don't understand. What specifically are you trying to do that is not convenient? I don't understand what you mean when you say you want to check the data.
    The php script abovementioned can work only on the "users" table inside MySQL database. If there are several tables inside under different name, I must create several scripts to read them. I think one php script wouldn't work on all "tables".
    Use SHA1. If someone registers for a new account and uses the password "test", you run "test" through SHA1 and get "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3", which is what you store in the database. When the user logs in again and you want to check their password, you run the password they entered through SHA1 and see if the SHA1 hash from the password they entered matches the SHA1 hash you saved in the database. If the hashes are the same then they entered the right password.
    Which package provides SHA1 command? I think SHA1 and sha1sum are NOT the same.B.R.satimis
  3. If you want to add a table border, most people just put a border attribute onto the table tag. Check the HTML reference for tables to see that.
    Hi justsomeguy,I got it done just adding border=1 inside <table border=1>. To increase the table size just use 2/3/4 etc.
    You can run the MySQL functions on any data, I'm not sure what your question is. You can run any MySQL function on any set of data in the database.
    I just want to check the data entered on the database tables. I'm NOT aware how to display the data using MySQL function. Now I use the php script instead. However if there are many tables I have to create many php scripts. It is NOT convenient.
    If you need to encrypt and decrypt, check one of the other functions that has a decrypt method, like the AES methods. Most systems today don't encrypt passwords in a way that can be decrypted, instead people usually hash the passwords. Hashes can't be decrypted. SHA-1 is a good hash to use. If you use a hash, you can't look up what someone's current password is. You can check if the password they enter is the same as the one they started with, but you can't look up what their password is. If someone forgets their password then you need to let them change it, you can't get the one they current have if you hash it.
    I just want to check whether the passwords entered are correct. Now I have to use copy/paste taking down what I have entered. I can't retrieve the password entered on hash. Maybe it can work only by intensive testing and guessing. If some body complains unable to login with his/her password then I have to create a new password for them.B.R.satimis
  4. That's because you're not telling it to output in table form, you're just having it print each column followed by "<br>".
    Modified the script as follow;
    <?php//These variables will determine the search parameters later$host="localhost"; //Database host.$user="root"; //Database username.$pass="apassword"; //Database password.$dbase="maildb"; //Database.$connect=mysql_connect($host,$user,$pass); //Connect to the database.mysql_select_db($dbase, $connect);//after the connection is made use the INSERT command to enter the values in the db$Q = "SELECT * FROM users"; // select everything//result set$result = mysql_query($Q);//creating the table /w headersecho "<html><body>";echo "<table><tr><td>id</td><td>name</td><td>crypt</td></tr>";//row for each recordwhile ($row = mysql_fetch_assoc ($result) ) { // loop through the result setecho"<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td><td>" . $row['crypt'] . "</td></tr>";}echo "</table>";echo "</body></html>";//close the dbmysql_close();?>

    Put it on /var/www/sqlusers.php. Fire a browser to evoke it. Then the output is displayed as table but without table frame. How to add it? TIA

    MySQL doesn't have a way to decrypt the passwords. The encrypt function uses the Unix crypt command to encrypt, so you may be able to use a system call to use crypt to decrypt the passwords. If you're going to be using encrypt, you need to give it a salt to use or else you won't be able to decrypt it because you won't know what the salt is. Check the documentation here:http://dev.mysql.com/doc/refman/5.1/en/enc...unction_encrypt
    Thanks for your URL. I need to digest it first. Is it to decrypt the encrypted password one by one? OR to display all of them on the table?B.R.satimis
  5. Do you have anything in the users table? It's only going to print information if it finds it in the users table. You can add print statements so that it tells you what it's trying to do, or how many records it found in the table.
    Yes, there are data on "users' table.mysql> DESCRIBE users;
    +-----------------+----------------------+------+-----+-------------------------+-------+| Field		   | Type				 | Null | Key | Default				 | Extra |+-----------------+----------------------+------+-----+-------------------------+-------+| id			  | varchar(128)		 | NO   | PRI |						 |	   | | name			| varchar(128)		 | NO   |	 |						 |	   | | uid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | gid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | home			| varchar(255)		 | NO   |	 | /var/spool/mail/virtual |	   | | maildir		 | varchar(255)		 | NO   |	 | blah/				   |	   | | enabled		 | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | change_password | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | clear		   | varchar(128)		 | NO   |	 | ChangeMe				|	   | | crypt		   | varchar(128)		 | NO   |	 | sdtrusfX0Jj66		   |	   | | quota		   | varchar(255)		 | NO   |	 |						 |	   | | procmailrc	  | varchar(128)		 | NO   |	 |						 |	   | | spamassassinrc  | varchar(128)		 | NO   |	 |						 |	   | +-----------------+----------------------+------+-----+-------------------------+-------+13 rows in set (0.00 sec)

    Ran following steps to enter data

    mysql> INSERT INTO users (id,name,maildir,crypt) VALUES	-> ('satimis@satimis.com','satimis','satimis/', encrypt('pass_A') ),	-> ('smsliu@satimis.com','smsliu','smsliu/', encrypt('pass_B') ),	-> ('albert@satimis.com','albert','albert/', encrypt('pass_C') ),	-> ('postmaster@satimis.com','postmaster','postmaster/', encrypt('pass_D') );etc.

    Edit:If changing

    ....	echo $row["column1"];	echo $row["column2"];	echo $row["column3"];....

    as;

    ....		echo $row['id'] . "<BR>";		echo $row['name'] . "<BR>";		echo $row['crypt'] . "<BR>";....

    Then it works;# php /home/satimis/sqlusers.php

    satimis@satimis.com<br>satimis<br>0e3QZ140ZrOOE<br>smsliu@satimis.com<br>smsliu<br>0eWBW8//TnfEg<br>albert@satimis.com<br>albert<br>XNP5IEvi8VZS6<br>patricia@satimis.com<br>patricia<br>0eg78AAkIGLWM<br>postmaster@satimis.com<br>postmaster<br>0e130m.vyL/aU<br>albertcheung@satimis.com<br>Albert Cheung<br>XXvTmrqgLrBGY<br>root@vz2:/#

    But the output is NOT in table form. The passwords are already encrypted. How to show the passwords in original text (i.e. before encrypted)? Thankssatimis

  6. It doesn't matter which directory you put that in. Make sure you connect to the database first. There are examples on this page:http://www.php.net/manual/en/function.mysql-fetch-assoc.php
    ThanksStill failPerformed following steps# mv /home/satimis/phpusers /home/satimis/sqlusers.php# cat /home/satimis/sqlusers.php
    <?php$host="localhost"; //Database host.$user="root"; //Database username.$pass="apassword"; //Database password.$dbase="maildb"; //Database.$connect=mysql_connect($host,$user,$pass); //Connect to the database.$Q = "SELECT * FROM users"; // select everything$result = mysql_query($Q);while ($row = mysql_fetch_assoc ($result) ) { // loop through the result set	echo $row["column1"];	echo $row["column2"];	echo $row["column2"];}?>

    # chmod +x /home/satimis/sqlusers.php # php /home/satimis/sqlusers.php

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/satimis/sqlusers.php on line 12

    line 12

    while ($row = mysql_fetch_assoc ($result) ) { // loop through the result set

    Edit:If adding following line on the script;

    mysql_select_db($dbase, $connect);

    after;

    $connect=mysql_connect($host,$user,$pass); //Connect to the database.

    Nothing print out on running the script;# php /home/satimis/sqlusers.php B.R.satimis

  7. The host is the server the database resides on, usually localhost. The user is root, aaa, etc.
    Hi Synook,Thanks for your advice.# cat /home/satimis/phpusers
    <?php$host="localhost"; //Database host.$user="root"; //Database username.$pass="apassword"; //Database password.$dbase="maildb"; //Database.$connect=mysql_connect($host,$user,$pass); //Connect to the database.$Q = "SELECT * FROM users"; // select everything$result = mysql_query($Q);while ($row = mysql_fetch_assoc ($result) ) { // loop through the result set	echo $row["column1"];	echo $row["column2"];	echo $row["column2"];}?>

    Where shall I run the script? If just run it on terminal it can't workroot@vz2:/# /home/satimis/phpusers

    /home/satimis/phpusers: line 1: ?php: No such file or directory/home/satimis/phpusers: line 3: =localhost: command not found/home/satimis/phpusers: line 3: //Database: No such file or directory/home/satimis/phpusers: line 4: =root: command not found/home/satimis/phpusers: line 4: //Database: No such file or directory/home/satimis/phpusers: line 5: =vz2mysqlroot: command not found/home/satimis/phpusers: line 5: //Database: No such file or directory/home/satimis/phpusers: line 6: =maildb: command not found/home/satimis/phpusers: line 6: //Database.: No such file or directory/home/satimis/phpusers: line 8: syntax error near unexpected token `$host,$user,$pass'/home/satimis/phpusers: line 8: `$connect=mysql_connect($host,$user,$pass); //Connect to the database.'

    Neither I understand what the errors indicate. Please help. TIAB.R.satimis

  8. You need to put it inside a web server directory, somewhere under public_html, and access it using a browser.
    Hi justsomeguy,Noted and thanks
    If you want to execute the script on the command line then you need to run the PHP binary and pass the filename of the script to execute. Your PHP script is also missing the database connection code.http://www.php.net/features.commandline
    PHP is also new to me.Whether adding following lines on top of the script
    $host="root"; //Database host.$user=""; //Database username.$pass="apassword"; //Database password.$dbase="maildb"; //Database.$connect=mysql_connect($host,$user,$pass); //Connect to the database.

    This is a test. Only root can access the database, "maildb". So I will leave "user" blank;

    $user=""; //Database username.

    ???If an user, "aaa" can access the database whether I leave the root blank instead;

    $host=" "; //Database host.

    TIAB.R.satimis

  9. It doesn't matter which directory you put that in. Make sure you connect to the database first. There are examples on this page:http://www.php.net/manual/en/function.mysql-fetch-assoc.php
    H justsomeguy,Thanks for your advice.php5 is running.mysql> SHOW tables;
    +------------------+| Tables_in_maildb |+------------------+| aliases		  | | domains		  | | users			| +------------------+3 rows in set (0.00 sec)

    # cat /home/satimis/phpusers

    <?php$Q = "SELECT * FROM users"; // select everything$result = mysql_query($Q);while ($row = mysql_fetch_assoc ($result) ) { // loop through the result set	echo $row["column1"];	echo $row["column2"];	echo $row["column2"];}?>

    # ls -l /home/satimis/phpusers

    -rwxr-xr-x 1 satimis satimis 244 May 27 01:22 /home/satimis/phpusers

    I can't not resolve where to run that script.if login the database it can't find the path/to/phpusersIf running the script direct on terminal it popup;# /home/satimis/phpusers

    /home/satimis/phpusers: line 1: ?php: No such file or directory/home/satimis/phpusers: line 3: =: command not found/home/satimis/phpusers: line 3: //: is a directory/home/satimis/phpusers: line 4: syntax error near unexpected token `('/home/satimis/phpusers: line 4: `$result = mysql_query($Q);'

    Please shed me some light. TIAB.R.satimis

  10. $Q = "SELECT * FROM my_table"; // select everything$result = mysql_query($Q);while ($row = mysql_fetch_assoc ($result) ) { // loop through the result set	echo $row["column1"];	echo $row["column2"];	echo $row["column2"];}

    Hi Deirdre's Dad,Where shall I put the php script, on which directory? ThanksB.R.satimis
  11. Hi folks,Ran following command to create aliases table

    mysql> CREATE TABLE `aliases` (	-> `pkid` smallint(3) NOT NULL auto_increment,	-> `mail` varchar(120) NOT NULL default '',	-> `destination` varchar(120) NOT NULL default '', 	-> `enabled` tinyint(1) NOT NULL default '1',	-> PRIMARY KEY (`pkid`),	-> UNIQUE KEY `mail` (`mail`)	-> );Query OK, 0 rows affected (0.01 sec)

    And ran following command to enter data

    mysql> INSERT INTO aliases (mail,destination) VALUES	-> ('albert@abc.com','albert@abc.com'),

    Now I need to change "albert@abc.com" to "albertlee@abc.com" running following command without sucess

    mysql> ALTER aliases CHANGE 'albert@abc.com', 'albertcheung@abc.com' varchar(120);mysql> ALTER aliases CHANGE 'albert@abc.com' 'albertcheung@abc.com';mysql> ALTER aliases CHANGE 'albert@abc.com', 'albertcheung@abc.com'; etc.

    Always syntax error.Please advise what will be the correct syntax? TIAWill MODIDY be the same as CHANGE?Can I use DROP to erase this email address? If YES please advise how? B.R.satimis

  12. Hi Synook,Thanks for your advice.

    The column definition is the data type and everything else, like you specified in the initial CREATE statement.
    If I don't change the column definition can I leave it without retyping it on the command?
    The [FIRST|AFTER col_name] section if for if you want to move the column's position to a different place.
    Could you please help me to understand the command to be entered? For example in my case;
    INSERT INTO users (id,name,maildir,clear) VALUES

    If I need to move "name" after "clear", whether typing;

    -> ALTER users CHANGE name | clear

    TIAB.R.satimis

  13. Change is used to alter an existing column in a MySQL table. You can use change to rename a column by providing both the old column name, and the new column name. It is written as: alter table [table name] change [old column name] [new column name] varchar (30) ;ALTER users CHANGE clear crypt varchar (30) ;
    Hi jlhaslip,Thanks for your advice.I'll run following commands
    mysql> USE database;mysql> ALTER users CHANGE clear crypt varchar (30);

    According to 12.1.7. ALTER TABLE Syntaxhttp://dev.mysql.com/doc/refman/5.1/en/alter-table.html

    CHANGE [COLUMN] old_col_name new_col_name column_definition		[FIRST|AFTER col_name]

    I suppose "varchar (30)" is column_definition ? Where to find it?What is

    [FIRST|AFTER col_name]

    ?TIAB.R.satimis

  14. Hi folks,Ran following entry creating a database;

    mysql> INSERT INTO users (id,name,maildir,clear) VALUES	-> ('xyz@aaa.com','xyz','xyz/', encrypt('password') ),	-> etc.	-> etc.	-> etc.;Query OK, 4 rows affected (0.00 sec)Records: 4  Duplicates: 0  Warnings: 0

    Now I need changing "clear" to "crypt"Please advise how to make such a change. TIAB.R.satimis

  15. You'll probably have to update the row again using the salt this time.
    Hi justsomeguy,Performed 2 tests as follows;1)
    mysql> UPDATE users SET `crypt`=encrypt('abcde','ab') WHERE id='root@localhost';Query OK, 1 row affected (0.03 sec)Rows matched: 1  Changed: 1  Warnings: 0

    mysql> SELECT crypt, encrypt('abcde','ab')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+----------------------------+| crypt		 | encrypt('abcde','ab') |+---------------+----------------------------+| ablOUJbYqen22 | ablOUJbYqen22			  | +---------------+----------------------------+1 row in set (0.00 sec)

    2)

    mysql> UPDATE users	-> SET crypt = encrypt('abcde','ab')	-> WHERE id = 'root@localhost';Query OK, 0 rows affected (0.01 sec)Rows matched: 1  Changed: 0  Warnings: 0

    mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)

    mysql> SELECT crypt, encrypt('abcde','ab')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+----------------------------+| crypt		 | encrypt('abcde','ab') |+---------------+----------------------------+| ablOUJbYqen22 | ablOUJbYqen22			  | +---------------+----------------------------+1 row in set (0.00 sec)

    They seem working. The output on left and right columns are identical.ThanksB.R.satimis

  16. - snip -If you use encrypt 5 times with no salt, you're going to get 5 different encrypted values. You need to use the same salt every time if you want the same results.
    Hi justsomeguy,Thanks for your advice. I got it.
    mysql> SELECT crypt, encrypt('abcde','ab')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+----------------------------+| crypt		 | encrypt('abcde','ab') |+---------------+----------------------------+| VpwUzEV/3gddQ | ab.myqrA0/jNA			  | +---------------+----------------------------+1 row in set (0.00 sec)

    Even running "N" times, the output on the right column remains unchanged. But still I can't find the 'left' and 'right' column output matched.B.R.satimis

  17. - snip -Have you looked on Google for how to change the root password for MySQL?
    Hi jesh,There is NOTHING to do with the root password. This password is used controlling a set of mysql files created on setting up this mail server running virtual domain. The confirmation on its correct change will clarify my doubt in case a problem popup on testing this mail server later. It is NOT the problem of the password changed.In the worst situation I just DROP this maildb and create a new one.Anyway thanks for your assistance and URL.B.R.satimis
  18. What you're looking at is the structure of the table, not the data that is contained in that table. The "sdtrusfX0Jj66" is the default value that would be assigned in the crypt column for a record that passed in a null value for that column. If you want to see the data, you have to run a select.Try this something like this:
    SELECT crypt, encrypt('abcde')FROM users WHERE id = 'root@localhost'

    If those two columns come back and have the same value, then the value that is in the database matches your encrypted "abcde" password.

    Hi jesh,Made 2 tests without result.1)Your version;
    mysql> UPDATE users									   	-> SET crypt = encrypt('abcde')	-> WHERE id = 'root@localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 0

    mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec)

    mysql> SElECT crypt, encrypt('abcde')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+-----------------------+| crypt		 |	encrypt('abcde')   |+---------------+-----------------------+| vBt2T6gFNegU6 | zHwuDiFRfEdZ.		 | +---------------+-----------------------+1 row in set (0.00 sec)

    2)My version;

    mysql> UPDATE users SET `crypt`=encrypt('abcde') WHERE id='root@localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 0

    mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)

    mysql> SELECt crypt, encrypt('abcde')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+-----------------------+| crypt		 |	encrypt('abcde'	|+---------------+-----------------------+| I4NOUUPuf8QqY | x5Gh8u9Cvx0hM		 | +---------------+-----------------------+1 row in set (0.00 sec)

    Edit:On your version, I ran following command twice. The output on the right column is different;

    mysql> SElECT crypt, encrypt('abcde')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+-----------------------+| crypt		 |	encrypt('abcde')	|+---------------+-----------------------+| vBt2T6gFNegU6 | zXozEmpE/CluM		 | +---------------+-----------------------+1 row in set (0.00 sec)

    mysql> SElECT crypt, encrypt('abcde')	-> FROM users	-> WHERE id = 'root@localhost';+---------------+-----------------------+| crypt		 |	encrypt('abcde')	|+---------------+-----------------------+| vBt2T6gFNegU6 | fZZHNIeMDHeY2		 | +---------------+-----------------------+1 row in set (0.00 sec)

    I also checked my version. Result was the same, value on right column changed. Value on left column remained the same.But the value on left column differed from the value generated from your version.B.R.satimis

  19. Have you tried something like this?
    UPDATE usersSET crypt = encrypt('abcde')WHERE id = 'root@localhost'

    Hi jesh,Thanks for your advice.I tried follow before;
    mysql> UPDATE users SET `crypt`=encrypt('abcde') WHERE id='root@localhost';Query OK, 1 row affected (0.02 sec)Rows matched: 1  Changed: 1  Warnings: 0

    It is similar to your advice.Then;

    mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec)

    But I found on ;

    mysql> DESCRIBE users;+-----------------+----------------------+------+-----+-------------------------+-------+| Field		   | Type				 | Null | Key | Default				 | Extra |+-----------------+----------------------+------+-----+-------------------------+-------+| id			  | varchar(128)		 | NO   | PRI |						 |	   | | name			| varchar(128)		 | NO   |	 |						 |	   | | uid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | gid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | home			| varchar(255)		 | NO   |	 | /var/spool/mail/virtual |	   | | maildir		 | varchar(255)		 | NO   |	 | blah/				   |	   | | enabled		 | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | change_password | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | clear		   | varchar(128)		 | NO   |	 | ChangeMe				|	   | | crypt		   | varchar(128)		 | NO   |	 | sdtrusfX0Jj66		   |	   | | quota		   | varchar(255)		 | NO   |	 |						 |	   | | procmailrc	  | varchar(128)		 | NO   |	 |						 |	   | | spamassassinrc  | varchar(128)		 | NO   |	 |						 |	   | +-----------------+----------------------+------+-----+-------------------------+-------+13 rows in set (0.00 sec)

    It seems no change;cryptdefault = sdtrusfX0Jj66as before.Tried your suggestion;

    mysql> UPDATE users	-> SET crypt = encrypt('abcde')	-> WHERE id = 'root@localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 0mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec)

    mysql> DESCRIBE users;

    +-----------------+----------------------+------+-----+-------------------------+-------+| Field		   | Type				 | Null | Key | Default				 | Extra |+-----------------+----------------------+------+-----+-------------------------+-------+| id			  | varchar(128)		 | NO   | PRI |						 |	   | | name			| varchar(128)		 | NO   |	 |						 |	   | | uid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | gid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | home			| varchar(255)		 | NO   |	 | /var/spool/mail/virtual |	   | | maildir		 | varchar(255)		 | NO   |	 | blah/				   |	   | | enabled		 | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | change_password | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | clear		   | varchar(128)		 | NO   |	 | ChangeMe				|	   | | crypt		   | varchar(128)		 | NO   |	 | sdtrusfX0Jj66		   |	   | | quota		   | varchar(255)		 | NO   |	 |						 |	   | | procmailrc	  | varchar(128)		 | NO   |	 |						 |	   | | spamassassinrc  | varchar(128)		 | NO   |	 |						 |	   | +-----------------+----------------------+------+-----+-------------------------+-------+13 rows in set (0.00 sec)

    Still the same.Is there any way to check whether password has been changed? TIAB.R.satimis

  20. Hi folks,Have created a database 'maildb' and ran following steps entering data afterwards.mysql> use maildb;mysql> show tables;

    +------------------+| Tables_in_maildb |+------------------+| aliases		  | | domains		  | | users			| +------------------+3 rows in set (0.01 sec)

    Ran following command mistakenly;

    mysql> INSERT INTO users (id,name,maildir,crypt) VALUES	-> ('root@localhost','root','root/', encrypt('apassword') );Query OK, 1 row affected (0.00 sec)

    Then exit mysql.I should replace 'apassword' with the password used on other files, say 'abcde'.Following data have been set on "users"mysql> DESCRIBE users;

    +-----------------+----------------------+------+-----+-------------------------+-------+| Field		   | Type				 | Null | Key | Default				 | Extra |+-----------------+----------------------+------+-----+-------------------------+-------+| id			  | varchar(128)		 | NO   | PRI |						 |	   | | name			| varchar(128)		 | NO   |	 |						 |	   | | uid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | gid			 | smallint(5) unsigned | NO   |	 | 5000					|	   | | home			| varchar(255)		 | NO   |	 | /var/spool/mail/virtual |	   | | maildir		 | varchar(255)		 | NO   |	 | blah/				   |	   | | enabled		 | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | change_password | tinyint(3) unsigned  | NO   |	 | 1					   |	   | | clear		   | varchar(128)		 | NO   |	 | ChangeMe				|	   | | crypt		   | varchar(128)		 | NO   |	 | sdtrusfX0Jj66		   |	   | | quota		   | varchar(255)		 | NO   |	 |						 |	   | | procmailrc	  | varchar(128)		 | NO   |	 |						 |	   | | spamassassinrc  | varchar(128)		 | NO   |	 |						 |	   | +-----------------+----------------------+------+-----+-------------------------+-------+13 rows in set (0.00 sec)

    I tried to correct the mistake with the correct password by running following commands without result;mysql> UPDATE users SET crypt='apassword'('abcde') WHERE id='root@localhost';

    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 '('abcde') WHERE id='root@localhost'' at line 1

    mysql> UPDATE users SET crypt=encrypt('apassword')(encrypt('abcde')) WHERE id='root@localhost';

    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 '(encrypt('abcde')) WHERE id='root@localhost'' at line 1

    mysql> UPDATE users SET crypt='encrypt('apassword')'(encrypt('abcde')) WHERE id='root@localhost';

    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 'apassword')'(encrypt('abcde')) WHERE id='root@localhost'' at line 1

    etc.Please advise the correct syntax to be used. TIAB.R.satimis

  21. since you've already renamed the column what you need now is:alter table virtual_domains modify name varchar(50) not null;
    mysql> DESCRIBE virtual_domains;
    +-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || name  | varchar(50) | YES  |	 | NULL	|				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

    mysql> ALTER TABLE virtual_domains	-> MODIFY name varchar(50) not null;Query OK, 0 rows affected (0.12 sec)Records: 0  Duplicates: 0  Warnings: 0

    mysql> DESCRIBE virtual_domains;

    +-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || name  | varchar(50) | NO   |	 |		 |				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

    the complete script would have beenalter virtual_domains change neme name varchar(50) not null;
    Noted with thanks.
    words between brackets are just comments they mustn't be included in the command.
    Noted and thanksB.R.satimis
  22. alter table virtual_domains change neme name varchar(50)

    Hi Stefano De Boni',Your advice works here. ThanksBefore reading your posting I tried following commands;mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] neme name;
    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 '[COLUMN] neme name' at line 2

    mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] 'neme' 'name';

    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 '[COLUMN] 'neme' 'name'' at line 2

    mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] neme name Field;

    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 '[COLUMN] neme name Field' at line 2

    mysql> ALTER TABLE virtual_domains -> CHANGE [COLUMN] 'neme' 'name' 'Field';

    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 '[COLUMN] 'neme' 'name' 'Field'' at line 2

    I can't resolve "column_definition". "varchar(50)" ? "No Null"?I read following manual;http://dev.mysql.com/doc/refman/5.0/en/alter-table.htmlplus some others found on googling. But the syntax confuses me.What is column_definition?What is {INDEX|KEY} [index_name], reference_definition, reference_definition, etc.They confuse me to certain extent. Also the error on the commands run by me previously always asking looking for the right version of MySQL.Are there MySQL documents with examples illustrated? TIAB.R.satimis

  23. Hi folks,I made a typing mistake "neme" on following table;mysql> DESCRIBE virtual_domains;

    +-------+-------------+------+-----+---------+----------------+| Field | Type		| Null | Key | Default | Extra		  |+-------+-------------+------+-----+---------+----------------+| id	| int(11)	 | NO   | PRI | NULL	| auto_increment || neme  | varchar(50) | NO   |	 |		 |				|+-------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

    Please advise how can I correct it instead of drop the table. TIAB.R.satimis

  24. Hi folks,mysql versionVer 14.12 Distrib 5.0.32I ran following command creating a table:-

    mysql> CREATE TABLE `tblPerdition` (	 -> `user` varchar(128),	 -> `servername` varchar(255) default '',	 -> `port` varchar(8) NULL default 'NULL', 	-> PRIMARY KEY (`user`) 	-> ); Query OK, 0 rows affected (0.00 sec)

    mysql> DESCRIBE tblPerdition;+------------+--------------+------+-----+---------+-------+| Field	  | Type		 | Null | Key | Default | Extra |+------------+--------------+------+-----+---------+-------+| user	   | varchar(128) | NO   | PRI |		 |	   || servername | varchar(255) | YES  |	 |		 |	   || port	   | varchar(8)   | YES  |	 | NULL	|	   |+------------+--------------+------+-----+---------+-------+3 rows in set (0.00 sec)

    I can't figure out how to made Null columns of 'user' blank (without NO)and 'servername' blank (without YES)Please help. TIAB.R.satimis

×
×
  • Create New...