锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品亚洲四区在线观看,亚洲AV无码一区二区一二区,国产亚洲精品影视在线产品http://www.tkk7.com/Javawind/archive/2008/05/27/203343.htmlkooyeekooyeeTue, 27 May 2008 14:28:00 GMThttp://www.tkk7.com/Javawind/archive/2008/05/27/203343.htmlhttp://www.tkk7.com/Javawind/comments/203343.htmlhttp://www.tkk7.com/Javawind/archive/2008/05/27/203343.html#Feedback1http://www.tkk7.com/Javawind/comments/commentRss/203343.htmlhttp://www.tkk7.com/Javawind/services/trackbacks/203343.htmlUsing Comments Effectively

The object of an effective coding style is to make the program more understandable and maintainable. Most programs will benefit from documentation which explains what is going on inside those programs. There are two forms of code documentation: external and internal. External documentation is descriptive information about a program which is written and stored separately from the program itself. Internal documentation, also known as inline documentation or comments, is placed within the program itself, either at the program level or the statement level. (For an introduction to inline documentation and the types of PL/SQL comments, see the section called "Comments" in Chapter 2.)

The best kind of internal documentation derives from your programming style. If you apply many of the guidelines in this chapter and throughout this book, you will be able to write code which is, to a great extent, self-documenting. Here are some general tips:

  • Write straightforward code that avoids clever tricks.

     

  • Think of names for variables and modules that accurately describe their purpose.

     

  • Use named constants instead of literal values.

     

  • Employ a clean, consistent layout.

     

Do all these things and more, and you will find that you need to write fewer comments to explain your code.

Reducing the need for comments is important. Few developers make or have the time for extensive documentation in addition to their development efforts, and, more importantly, many comments tend to duplicate the code. This raises a maintenance issue because those comments will have to be changed when the code is changed.

While it is my hope that after reading this book you will write more self-documenting code, there is little doubt that you will still need to comment your code. The following example shows the use of single- and multiline comments in PL/SQL:

PROCEDURE calc_totals (company_id IN NUMBER,--The company key
                       total_type IN VARCHAR2--ALL or NET
                      );
 
/*
|| For every employee hired more than five years ago,
|| give them a bonus and send them an e-mail notification.
*/
FOR emp_rec IN emp_cur (ADD_MONTHS (SYSDATE, -60))
LOOP
   apply_bonus (emp_rec.employee_id);
   send_notification (emp_rec.employee_id);
END LOOP;
 
-- IF :SYSTEM.FORM_STATUS = 'CHANGED' THEN COMMIT; END IF;
 
FUNCTION display_user 
   (user_id IN NUMBER /* Must be valid ID */, user_type IN VARCHAR2)

The first example uses the single-line comment syntax to include endline descriptions for each parameter in the procedure specification. The second example uses a multiline comment to explain the purpose of the FOR loop. The third example uses the double-hyphen to comment out a whole line of code. The last example embeds a comment in the middle of a line of code using the block comment syntax.

These two types of comments offer the developer flexibility in how to provide inline documentation. The rest of this section offers guidelines for writing effective comments in your PL/SQL programs.

Comment As You Code

It is very difficult to make time to document your code after you have finished writing your program. Psychologically, you want to (and often need to) move on to the next programming challenge after you get a program working.

You may also have a harder time writing your comments once you have put some distance between your brain cells and those lines of code. Why exactly did you write the loop that way? Where precisely is the value of that global variable set? Unless you have total recall, post-development documentation can be a real challenge.

The last and perhaps most important reason to write your comments as you write your code is that the resulting code will have fewer bugs and (independent of the comments themselves) be easier to understand.

When you write a comment you (theoretically) explain what your code is meant to accomplish. If you find it difficult to come up with that explanation, there is a good chance that you lack a full understanding of what the program does or should do.

The effort that you make to come up with the right comment will certainly improve your comprehension, and may also result in code correction. In this sense, good inline documentation can be as beneficial as a review of your code by a peer. In both cases, the explanation will reveal important information about your program.

Explain the Why--Not the How--of Your Program

What do you think of the comments in the following Oracle Forms trigger code?

-- If the total compensation is more than the maximum...
IF :employee.total_comp > maximum_salary
THEN
   -- Inform the user of the problem.
   MESSAGE ('Total compensation exceeds maximum. Please re-enter!');
 
   -- Reset the counter to zero.
   :employee.comp_counter := 0;
 
   -- Raise the exception to stop trigger processing.
   RAISE FORM_TRIGGER_FAILURE;
END IF;

None of these comments add anything to the comprehension of the code. Each comment simply restates the line of code, which in most cases is self-explanatory.

Avoid adding comments simply so that you can say, "Yes, I documented my code!" Rely as much as possible on the structure and layout of the code itself to express the meaning of the program. Reserve your comments to explain the Why of your code: What business rule is it meant to implement? Why did you need to implement a certain requirement in a certain way?

In addition, use comments to translate internal, computer-language terminology into something meaningful for the application. Suppose you are using Oracle Forms GLOBAL variables to keep track of a list of names entered. Does the following comment explain the purpose of the code or simply restate what the code is doing?

/* Set the number of elements to zero. */
:GLOBAL.num_elements := 0;

Once again, the comment adds no value. Does the next comment offer additional information?

/* Empty the list of names. */
:GLOBAL.num_elements := 0;

This comment actually explains the purpose of the assignment of the global to zero. By setting the number of elements to zero, I will have effectively emptied the list. This comment has translated the "computer lingo" into a description of the effect of the statement. Of course, you would be even better off hiding the fact that you use this particular global variable to empty a list and instead build a procedure as follows:

PROCEDURE empty_list IS

BEGIN

:GLOBAL.num_elements := 0;

END;

Then to empty a list you would not need any comment at all. You could simply include the statement:

empty_list;

and the meaning would be perfectly clear.

Make Comments Easy to Enter and Maintain

You shouldn't spend a lot of time formatting your comments. You need to develop a style that is clean and easy to read, but also easy to maintain. When you have to change a comment, you shouldn't have to reformat every line in the comment. Lots of fancy formatting is a good indication that you have a high-maintenance documentation style. The following block comment is a maintenance nightmare:

/*
===========================================================
| Parameter          Description                          |
|                                                         |
| company_id         The primary key to company           |
| start_date         Start date used for date range       |
| end_date           End date for date range              |
===========================================================
*/

The right-justified vertical lines and column formatting for the parameters require way too much effort to enter and maintain. What happens if you add a parameter with a very long name? What if you need to write a longer description? A simpler and more maintainable version of this comment might be:

/*
===========================================================
| Parameter - Description               
|                                                         
| company_id - The primary key to company 
| start_date - Start date used for date range 
| end_date - End date for date range       
===========================================================
*/

I like to use the following format for my block comments:

/*
|| I put the slash-asterisk that starts the comment on a line all by
|| itself. Then I start each line in the comment block with a double

|| vertical bar to highlight the presence of the comment. Finally,

|| I place the asterisk-slash on a line all by itself.

*/

On the negative side, the vertical bars have to be erased whenever I reformat the lines, but that isn't too much of an effort. On the positive side, those vertical bars make it very easy for a programmer who is scanning the left side of the code to pick out the comments.

I put the comment markers on their own lines to increase the whitespace in my program and set off the comment. That way I can avoid "heavy" horizontal lines full of delimiters, such as asterisks or dashes, and avoid having to match the longest line in the comment.

Maintain Indentation

Inline commentary should reinforce the indentation and therefore the logical structure of the program. For example, it is very easy to find the comments in the make_array procedures shown below. I do not use any double-hyphens, so the slash-asterisk sequences stand out nicely. In addition, all comments start in the first column, so I can easily scan down the left-hand side of the program and pick out the documentation:

PROCEDURE make_array (num_rows_in IN INTEGER) 
/* Create an array of specified numbers of rows */
IS
/* Handles to Oracle Forms structures */
   col_id GROUPCOLUMN;
   rg_id RECORDGROUP;
BEGIN
/* Create new record group and column */
   rg_id := CREATE_GROUP ('array');
   col_id := ADD_GROUP_COLUMN ('col');
/* 
|| Use a loop to create the specified number of rows and 
|| set the value in each cell.
*/
   FOR row_index IN 1 .. num_rows_in
   LOOP
/* Create a row at the end of the group to accept data */
      ADD_GROUP_ROW (return_value, END_OF_GROUP);
      FOR col_index IN 1 .. num_columns_in
      LOOP
/* Set the initial value in the cell */
         SET_GROUP_NUMBER_CELL (col_id, row_index, 0); 

END LOOP;

   END LOOP;
END;

The problem with these comments is precisely that they do all start in the first column, regardless of the code they describe. The most glaring example of this formatting "disconnect" comes in the inner loop, repeated below:

      FOR col_index IN 1 .. num_columns_in
      LOOP
/* Set the initial value in the cell */
         SET_GROUP_NUMBER_CELL (col_id, row_index, 0); 
      END LOOP;

Your eye follows the three-space indentation very smoothly into the loop and then you are forced to move all the way to the left to pick up the comment. This format disrupts your reading of the code and therefore its readability. The code loses some of its ability to communicate the logical flow "at a glance," because the physical sense of indentation as logical flow is marred by the comments. Finally, you may end up writing full-line comments which are much longer than the code they appear next to, further distorting the code.

Your comments should always be indented at the same level as the code which they describe. Assuming the comments come before the code itself, those lines of descriptive text will initiate the indentation at that logical level, which will also reinforce that structure. The make_array procedure, properly indented, is shown below:

PROCEDURE make_array (num_rows_in IN INTEGER) 
/* Create an array of specified numbers of rows */
IS
   /* Handles to Oracle Forms structures */
   col_id GROUPCOLUMN;
   rg_id RECORDGROUP;
BEGIN
   /* Create new record group and column */
   rg_id := CREATE_GROUP ('array');
   col_id := ADD_GROUP_COLUMN ('col');
   /* 
   || Use a loop to create the specified number of rows and 
   || set the value in each cell.
   */
   FOR row_index IN 1 .. num_rows_in
   LOOP
      /* Create a row at the end of the group to accept data */
      ADD_GROUP_ROW (return_value, END_OF_GROUP);
      FOR col_index IN 1 .. num_columns_in
      LOOP
         /* Set the initial value in the cell */
         SET_GROUP_NUMBER_CELL (col_id, row_index, 0); 

END LOOP;

END LOOP;

END;

Comment Declaration Statements

I propose the following simple rule for documenting declaration statements:

Provide a comment for each and every declaration.

Does that sound excessive? Well, I must admit that I do not follow this guideline at all times, but I bet people who read my code wish I had. The declaration of a variable which seems to me to be perfectly clear may be a source of abiding confusion for others. Like many other people, I still have difficulty understanding that what is obvious to me is not necessarily obvious to someone else.

Consider the declaration section in the next example. The commenting style is inconsistent. I use double-hyphens for a two-line comment; then I use the standard block format to provide information about three variables all at once. I provide comments for some variables, but not for others. It's hard to make sense of the various declaration statements:

DECLARE
   -- Assume a maximum string length of 1000 for a line of text.
   text_line VARCHAR2 (1000);
   len_text    NUMBER;
   /*
   || Variables used to keep track of string scan:
   ||    atomic_count - running count of atomics scanned.
   ||    still_scanning - Boolean variable controls WHILE loop.
   */
   atomic_count NUMBER := 1;
   still_scanning BOOLEAN;
BEGIN

Let's recast this declaration section using my proposed guideline: a comment for each declaration statement. In the result shown below, the declaration section is now longer than the first version, but it uses whitespace more effectively. Each declaration has its own comment, set off by a blank line if a single-line comment:

DECLARE
   /* Assume a maximum string length of 1000 for a line of text. */
   text_line VARCHAR2 (1000);
 
   /* Calculate length of string at time of declaration */
   len_string NUMBER;
 
   /* Running count of number of atomics scanned */
   atomic_count NUMBER := 1;
 
   /* Boolean variable that controls WHILE loop */
   still_scanning BOOLEAN ;
BEGIN


kooyee 2008-05-27 22:28 鍙戣〃璇勮
]]>
[Oracle]each row and table level triggershttp://www.tkk7.com/Javawind/archive/2008/04/05/190965.htmlkooyeekooyeeSat, 05 Apr 2008 11:36:00 GMThttp://www.tkk7.com/Javawind/archive/2008/04/05/190965.htmlhttp://www.tkk7.com/Javawind/comments/190965.htmlhttp://www.tkk7.com/Javawind/archive/2008/04/05/190965.html#Feedback0http://www.tkk7.com/Javawind/comments/commentRss/190965.htmlhttp://www.tkk7.com/Javawind/services/trackbacks/190965.html
table level triggers: 鏄痶able鏀瑰彉鏃訛紝瑙﹀彂trigger銆傛棤璁哄嚑涓猺ow鏀瑰彉閮芥病褰卞搷, 姣斿錛?涓猺ow update瑙﹀彂1嬈?,錛掍釜row update錛屼篃瑙﹀彂1嬈°?br />
欏轟究杞釜鏁欑▼

Before / for each row trigger

A before trigger is called before because it fires before the new values (:new.field_name) are stored in the table. That means that the new value can be changed in the trigger.
create table t_update_before_each_row (
txt varchar2(10)
);
create table log (
txt varchar2(20)
);
create trigger update_before_each_row
before update on t_update_before_each_row
for each row
begin
:new.txt := upper(:new.txt);
insert into log values ('old: ' || :old.txt);
insert into log values ('new: ' || :new.txt);
end update_before_each_row;
/
insert into t_update_before_each_row values('one');
insert into t_update_before_each_row values('two');
insert into t_update_before_each_row values('three');
insert into t_update_before_each_row values('four');
Updating (that is: concatenating the value with itself) the rows containing two and three:
update t_update_before_each_row set txt = txt || txt
where substr(txt,1,1) = 't';
select * from t_update_before_each_row;
As can be seen by the output of the select statement, the trigger changed the values of the new values; they're in uppercase now:
one
TWOTWO
THREETHREE
four
The log displays the old and new values:
select * from log;
old: two
new: TWOTWO
old: three
new: THREETHREE
Cleaning up:
drop table t_update_before_each_row;
drop table log;

After / for each row trigger

In contrast to a before trigger, an after trigger does not allow to change :new.field_name because the value is, when the trigger fires, already written to the table.
If one tries to assign a value to :new.field_name, Oracle throws an ORA-04084: cannot change NEW values for this trigger type.
create table t_update_after_each_row (
txt varchar2(10)
);
create table log (
txt varchar2(20)
);
create trigger update_after_each_row
after update on t_update_after_each_row
for each row
begin
-- :new.txt := upper(:old.txt); -- ORA-04084: cannot change NEW values for this trigger type
insert into log values ('old: ' || :old.txt);
insert into log values ('new: ' || :new.txt);
end update_after_each_row;
/
insert into t_update_after_each_row values('one');
insert into t_update_after_each_row values('two');
insert into t_update_after_each_row values('three');
insert into t_update_after_each_row values('four');
update t_update_after_each_row set txt = txt || txt
where substr(txt,1,1) = 't';
select * from t_update_after_each_row;
one
twotwo
threethree
four
select * from log;
As the log table shows, it is possible to use :new and :old although it's not possible to assign something to :new.
old: two
new: twotwo
old: three
new: threethree
Cleaning up:
drop table t_update_after_each_row;
drop table log;

Table level trigger

A table level trigger is a trigger that doesn't fire for each row to be changed. Accordingly, it lacks the for each row. Consequently, both, the :new and :old are not permitted in the trigger's PL/SQL block, otherwise, an ORA-04082: NEW or OLD references not allowed in table level triggers is thrown.
create table t_update_before (
txt varchar2(10)
);
create table log (
txt varchar2(20)
);
create trigger update_before
before update on t_update_before
begin
-- :new.txt := upper(:old.txt); -- ORA-04082
insert into log values ('update trigger');
end update_before;
/
insert into t_update_before values('one');
insert into t_update_before values('two');
insert into t_update_before values('three');
insert into t_update_before values('four');
update t_update_before set txt = txt || txt
where substr(txt,1,1) = 't';
select * from t_update_before;
one
twotwo
threethree
four
Although two rows were updated, only one record is found in the log table:
select * from log;
update trigger
An update statement that doesn't update any row:
update t_update_before set txt = txt || txt
where txt = 'no update';
Still, the trigger fires...
select * from log;
... which results in another row found in the log table:
update trigger
update trigger
Cleaning up:
drop table t_update_before;
drop table log;

Order of execution

Oracle allows to create multiple triggers on the same table. The order of the execution of these triggers is undeterministic (or random, if you want this word) except that all before triggers fire before the after triggers.


kooyee 2008-04-05 19:36 鍙戣〃璇勮
]]>
[MYSQL] SQLException: No suitable driverhttp://www.tkk7.com/Javawind/archive/2007/11/16/161111.htmlkooyeekooyeeFri, 16 Nov 2007 12:33:00 GMThttp://www.tkk7.com/Javawind/archive/2007/11/16/161111.htmlhttp://www.tkk7.com/Javawind/comments/161111.htmlhttp://www.tkk7.com/Javawind/archive/2007/11/16/161111.html#Feedback0http://www.tkk7.com/Javawind/comments/commentRss/161111.htmlhttp://www.tkk7.com/Javawind/services/trackbacks/161111.html闂鍙兘鏄?寤虹珛database榪炴帴鏃訛紝url鐨勬牸寮忎笉姝g‘寮曡搗鐨勩?br />
姝g‘鏍煎紡涓?

jdbc:mysql://localhost : 3306/database


kooyee 2007-11-16 20:33 鍙戣〃璇勮
]]>
MySQL 5.1鍙傝冩墜鍐?/title><link>http://www.tkk7.com/Javawind/archive/2007/11/10/159615.html</link><dc:creator>kooyee</dc:creator><author>kooyee</author><pubDate>Sat, 10 Nov 2007 13:00:00 GMT</pubDate><guid>http://www.tkk7.com/Javawind/archive/2007/11/10/159615.html</guid><wfw:comment>http://www.tkk7.com/Javawind/comments/159615.html</wfw:comment><comments>http://www.tkk7.com/Javawind/archive/2007/11/10/159615.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/Javawind/comments/commentRss/159615.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/Javawind/services/trackbacks/159615.html</trackback:ping><description><![CDATA[http://dev.mysql.com/doc/refman/5.1/zh/index.html<br /> <br /> <div id="jkqkqml" class="titlepage"> <div> <div> <h2 class="title"><a name="user-account-management"></a>5.8. MySQL鐢ㄦ埛璐︽埛綆$悊</h2> </div> </div> </div> <div id="tqhriph" class="toc"> <dl> <dt><span id="stdqdzr" class="section"><a >5.8.1. MySQL鐢ㄦ埛鍚嶅拰瀵嗙爜</a></span> <dt><span id="mcezqie" class="section"><a >5.8.2. 鍚慚ySQL澧炲姞鏂扮敤鎴瘋處鎴?/a></span> <dt><span id="mnxhume" class="section"><a >5.8.3. 浠嶮ySQL鍒犻櫎鐢ㄦ埛璐︽埛</a></span> <dt><span id="ykuarjx" class="section"><a >5.8.4. 闄愬埗璐︽埛璧勬簮</a></span> <dt><span id="sprxdvn" class="section"><a >5.8.5. 璁劇疆璐︽埛瀵嗙爜</a></span> <dt><span id="yntzyma" class="section"><a >5.8.6. 浣夸綘鐨勫瘑鐮佸畨鍏?/a></span> <dt><span id="efhctld" class="section"><a >5.8.7. 浣跨敤瀹夊叏榪炴帴</a></span></dt></dl></div> <br /> <div id="abofhdg" class="titlepage"> <div> <div> <h3 class="title"><a name="adding-users"></a>5.8.2. 鍚慚ySQL澧炲姞鏂扮敤鎴瘋處鎴?/h3> </div> </div> </div> <a class="indexterm" name="id2774260"></a><a class="indexterm" name="id2774269"></a><a class="indexterm" name="id2774281"></a><a class="indexterm" name="id2774291"></a><a class="indexterm" name="id2774302"></a><a class="indexterm" name="id2774312"></a><a class="indexterm" name="id2774322"></a> <p>鍙互鐢ㄤ袱縐嶆柟寮忓垱寤?span>MySQL</span>璐︽埛錛?/p> <p><span>·<span>         </span></span>浣跨敤<span>GRANT</span>璇彞</p> <p><span>·<span>         </span></span>鐩存帴鎿嶄綔<span>MySQL</span>鎺堟潈琛?/p> <p>鏈濂界殑鏂規(guī)硶鏄嬌鐢?span>GRANT</span>璇彞錛屽洜涓鴻繖鏍鋒洿綺劇‘錛岄敊璇皯銆備粠<span>MySQL 3.22.11</span>璧鋒彁渚涗簡(jiǎn)<span>GRANT</span>錛涘叾璇硶瑙?a title="13.5.1.3. GRANT and REVOKE Syntax" >13.5.1.3鑺傦紝“GRANT鍜孯EVOKE璇硶”</a>銆?/p> <p>鍒涘緩璐︽埛鐨勫叾瀹冩柟娉曟槸浣跨敤<span>MySQL</span>璐︽埛綆$悊鍔熻兘鐨勭涓夋柟紼嬪簭銆?span>phpMyAdmin</span>鍗蟲槸涓涓▼搴忋?/p> <p>涓嬮潰鐨勭ず渚嬭鏄庡浣曚嬌鐢?strong><span 瀹嬩綋;?>MySQL</span></strong>瀹㈡埛绔▼搴忔潵璁劇疆鏂扮敤鎴楓傚亣瀹氭寜鐓?a title="2.9.3. Securing the Initial MySQL Accounts" >2.9.3鑺傦紝“浣垮垵濮婱ySQL璐︽埛瀹夊叏”</a>鎻忚堪鐨?榛樿鍊兼潵璁劇疆鏉冮檺銆傝繖璇存槑涓轟簡(jiǎn)鏇存敼錛屼綘蹇呴』浠?span>MySQL </span><span>root</span>鐢ㄦ埛榪炴帴<span>MySQL</span>鏈嶅姟鍣紝騫朵笖<span>root</span>璐︽埛蹇呴』鏈?span>mysql</span>鏁版嵁搴撶殑<span>INSERT</span>鏉冮檺鍜?span>RELOAD</span>綆$悊鏉冮檺銆?/p> <p>棣栧厛錛屼嬌鐢?strong><span 瀹嬩綋;?>MySQL</span></strong>紼嬪簭浠?span>MySQL </span><span>root</span>鐢ㄦ埛鏉ヨ繛鎺ユ湇鍔″櫒錛?/p> <pre><span>shell> </span><span>MySQL<strong> --user=root </strong>MySQL</span></pre> <p>濡傛灉浣犱負(fù)<span>root</span>璐︽埛鎸囧畾浜?jiǎn)瀵嗙爜锛寴q橀渶瑕佷負(fù)璇?strong><span>MySQL</span></strong>鍛戒護(hù)鍜屾湰鑺備腑鐨勫叾瀹冨懡浠ゆ彁渚?span>--password</span>鎴?span>-p</span>閫夐」銆?/p> <p><span>浠?span>root</span></span>榪炴帴鍒版湇鍔″櫒涓婂悗錛屽彲浠ユ坊鍔犳柊璐︽埛銆備笅闈㈢殑璇彞浣跨敤<span>GRANT</span>鏉ヨ緗洓涓柊璐︽埛錛?/p> <pre><span>mysql> </span><span><strong><span>GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'some_pass' WITH GRANT OPTION;</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'some_pass' WITH GRANT OPTION;</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT USAGE ON *.* TO 'dummy'@'localhost';</span></strong></span></pre> <p>鐢?span>GRANT</span>璇彞鍒涘緩鐨勮處鎴鋒湁涓嬮潰鐨勫睘鎬э細(xì)</p> <p><span>·<span>         </span></span>鍏朵腑涓や釜璐︽埛鏈夌浉鍚岀殑鐢ㄦ埛鍚?span>monty</span>鍜屽瘑鐮?span>some_pass</span>銆備袱涓處鎴峰潎涓鴻秴綰х敤鎴瘋處鎴鳳紝鍏鋒湁瀹屽叏鐨勬潈闄愬彲浠ュ仛浠諱綍浜嬫儏銆備竴涓處鎴?span> (</span><span>'monty'@'localhost'</span><span>)</span>鍙敤浜庝粠鏈満榪炴帴鏃躲傚彟涓涓處鎴?span>(</span><span>'monty'@'%'</span><span>)</span>鍙敤浜庝粠鍏跺畠涓繪満榪炴帴銆傝娉ㄦ剰<span>monty</span>鐨勪袱涓處鎴峰繀欏昏兘浠庝換浣曚富鏈轟互<span>monty</span>榪炴帴銆傛病鏈?span>localhost</span>璐︽埛錛屽綋<span>monty</span>浠庢湰鏈鴻繛鎺ユ椂錛?strong><span>mysql_install_db</span></strong>鍒涘緩鐨?span>localhost</span>鐨勫尶鍚嶇敤鎴瘋處鎴峰皢鍗犲厛銆傜粨鏋滄槸錛?span>monty</span>灝嗚瑙嗕負(fù)鍖垮悕鐢ㄦ埛銆傚師鍥犳槸鍖垮悕鐢ㄦ埛璐︽埛鐨?span>Host</span>鍒楀兼瘮<span>'monty'@'%'</span>璐︽埛鏇村叿浣擄紝榪欐牱鍦?span>user</span>琛ㄦ帓搴忛『搴忎腑鎺掑湪鍓嶉潰銆?span>(</span><span>user</span>琛ㄦ帓搴忕殑璁ㄨ鍙傝<a title="5.7.5. Access Control, Stage 1: Connection Verification" >5.7.5鑺傦紝“璁塊棶鎺у埗, 闃舵1錛氳繛鎺ユ牳瀹?#8221;</a>錛?span>銆?</span></p> <p><span>·<span>         </span></span>涓涓處鎴鋒湁鐢ㄦ埛鍚?span>admin</span>錛屾病鏈夊瘑鐮併傝璐︽埛鍙敤浜庝粠鏈満榪炴帴銆傛巿浜堜簡(jiǎn)<span>RELOAD</span>鍜?span>PROCESS</span>綆$悊鏉冮檺銆傝繖浜涙潈闄愬厑璁?span>admin</span>鐢ㄦ埛鎵ц<strong><span>mysqladmin reload</span></strong>銆?strong><span>mysqladmin refresh</span></strong>鍜?strong><span>mysqladmin flush-</span></strong><span><strong><em><span>xxx</span></em></strong></span>鍛戒護(hù)錛屼互鍙?strong><span>mysqladmin processlist</span></strong>銆傛湭鎺堜簣璁塊棶鏁版嵁搴撶殑鏉冮檺銆備綘鍙互閫氳繃<span>GRANT</span>璇彞娣誨姞姝ょ被鏉冮檺銆?/p> <p><span>·<span>         </span></span>涓涓處鎴鋒湁鐢ㄦ埛鍚?span>dummy</span>錛屾病鏈夊瘑鐮併傝璐︽埛鍙敤浜庝粠鏈満榪炴帴銆傛湭鎺堜簣鏉冮檺銆傞氳繃<span>GRANT</span>璇彞涓殑<span>USAGE</span>鏉冮檺錛屼綘鍙互鍒涘緩璐︽埛鑰屼笉鎺堜簣浠諱綍鏉冮檺銆傚畠鍙互灝嗘墍鏈夊叏灞鏉冮檺璁句負(fù)<span>'N'</span>銆傚亣瀹氫綘灝嗗湪浠ュ悗灝嗗叿浣撴潈闄愭巿浜堣璐︽埛銆?/p> <p>闄や簡(jiǎn)<span>GRANT</span>錛屼綘鍙互鐩存帴鐢?span>INSERT</span>璇彞鍒涘緩鐩稿悓鐨勮處鎴鳳紝鐒跺悗浣跨敤<span>FLUSH PRIVILEGES</span>鍛婅瘔鏈嶅姟鍣ㄩ噸杞芥巿鏉冭〃錛?/p> <pre><span>shell> </span><span><strong><span>mysql --user=root mysql</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('localhost','monty',PASSWORD('some_pass'),</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('%','monty',PASSWORD('some_pass'),</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user SET Host='localhost',User='admin',</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>Reload_priv='Y', Process_priv='Y';</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user (Host,User,Password)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('localhost','dummy','');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>FLUSH PRIVILEGES;</span></strong></span></pre> <p>褰撲綘鐢?span>INSERT</span>鍒涘緩璐︽埛鏃朵嬌鐢?span>FLUSH PRIVILEGES</span>鐨勫師鍥犳槸鍛婅瘔鏈嶅姟鍣ㄩ噸璇繪巿鏉冭〃銆傚惁鍒欙紝鍙湁閲嶅惎鏈嶅姟鍣ㄥ悗鏇存敼鏂逛細(xì)琚敞鎰忓埌銆備嬌鐢?<span>GRANT</span>錛屽垯涓嶉渶瑕佷嬌鐢?span>FLUSH PRIVILEGES</span>銆?/p> <p>鐢?span>INSERT</span>浣跨敤<span>PASSWORD()</span>鍑芥暟鏄負(fù)浜?jiǎn)鍔犲瘑瀵嗙爜銆?span>GRANT</span>璇彞涓轟綘鍔犲瘑瀵嗙爜錛屽洜姝や笉闇瑕?span>PASSWORD()</span>銆?/p> <p><span>'Y'</span>鍊煎惎鐢ㄨ處鎴鋒潈闄愩傚浜?span>admin</span>璐︽埛錛岃繕鍙互浣跨敤鏇村姞鍙鐨?span>INSERT</span>鎵╁厖鐨勮娉曪紙浣跨敤<span>SET</span>錛夈?/p> <p>鍦ㄤ負(fù)<span>dummy</span>璐︽埛鐨?span>INSERT</span>璇彞涓紝鍙湁<span>user</span>琛ㄤ腑鐨?span>Host</span>銆?span>User</span>鍜?span>Password</span>鍒楄褰曚負(fù)鎸囧畾鐨勫箋傛病鏈変竴涓潈闄愬垪涓烘樉寮忚緗紝鍥犳<span>MySQL</span>灝嗗畠浠潎鎸囧畾涓?榛樿鍊?span>'N'</span>銆傝繖鏍風(fēng)瓑鍚屼簬<span>GRANT USAGE</span>鐨勬搷浣溿?/p> <p>璇鋒敞鎰忚璁劇疆瓚呯駭鐢ㄦ埛璐︽埛錛屽彧闇瑕佸垱寤轟竴涓潈闄愬垪璁劇疆涓?span>'Y'</span>鐨?span>user</span>琛ㄦ潯鐩?span>user</span>琛ㄦ潈闄愪負(fù)鍏ㄥ眬鏉冮檺錛屽洜姝ゅ叾瀹?鎺堟潈琛ㄤ笉鍐嶉渶瑕佹潯鐩?/p> <p>涓嬮潰鐨勪緥瀛愬垱寤?span>3</span>涓處鎴鳳紝鍏佽瀹冧滑璁塊棶涓撶敤鏁版嵁搴撱傛瘡涓處鎴風(fēng)殑鐢ㄦ埛鍚嶄負(fù)<span>custom</span>錛屽瘑鐮佷負(fù)<span><span>obscure</span>銆?/span></p> <p>瑕佹兂鐢?span>GRANT</span>鍒涘緩璐︽埛錛屼嬌鐢ㄤ笅闈㈢殑璇彞錛?/p> <pre><span>shell> </span><span>MySQL<strong> --user=root </strong>MySQL</span></pre> <pre><span>shell> </span><span><strong><span>mysql --user=root mysql</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>ON bankaccount.*</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>TO 'custom'@'localhost'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'obscure';</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>ON expenses.*</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>TO 'custom'@'whitehouse.gov'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'obscure';</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>ON customer.*</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>TO 'custom'@'server.domain'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'obscure';</span></strong></span></pre> <p>榪?span>3</span>涓處鎴峰彲浠ョ敤浜庯細(xì)</p> <p><span>·<span>         </span></span>絎?span>1</span>涓處鎴峰彲浠ヨ闂?span>bankaccount</span>鏁版嵁搴擄紝浣嗗彧鑳戒粠鏈満璁塊棶銆?/p> <p><span>·<span>         </span></span>絎?span>2</span>涓處鎴峰彲浠ヨ闂?span>expenses</span>鏁版嵁搴擄紝浣嗗彧鑳戒粠涓繪満<span>whitehouse.gov</span>璁塊棶銆?/p> <p><span>·<span>         </span></span>絎?span>3</span>涓處鎴峰彲浠ヨ闂?span>customer</span>鏁版嵁搴擄紝浣嗗彧鑳戒粠涓繪満<span>server.domain</span>璁塊棶銆?/p> <p>瑕佹兂涓嶇敤<span>GRANT</span>璁劇疆<span>custom</span>璐︽埛錛屼嬌鐢?span>INSERT</span>璇彞鐩存帴淇敼 鎺堟潈琛細(xì)</p> <pre><span>shell> </span><span><strong><span>mysql --user=root mysql</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user (Host,User,Password)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('localhost','custom',PASSWORD('obscure'));</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user (Host,User,Password)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('whitehouse.gov','custom',PASSWORD('obscure'));</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO user (Host,User,Password)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('server.domain','custom',PASSWORD('obscure'));</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO db</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>(Host,Db,User,Select_priv,Insert_priv,</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>Update_priv,Delete_priv,Create_priv,Drop_priv)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('localhost','bankaccount','custom',</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>'Y','Y','Y','Y','Y','Y');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO db</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>(Host,Db,User,Select_priv,Insert_priv,</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>Update_priv,Delete_priv,Create_priv,Drop_priv)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('whitehouse.gov','expenses','custom',</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>'Y','Y','Y','Y','Y','Y');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>INSERT INTO db</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>(Host,Db,User,Select_priv,Insert_priv,</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>Update_priv,Delete_priv,Create_priv,Drop_priv)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('server.domain','customer','custom',</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>'Y','Y','Y','Y','Y','Y');</span></strong></span></pre> <pre><span>mysql> </span><span><strong><span>FLUSH PRIVILEGES;</span></strong></span></pre> <pre><span> </span></pre> <p>鍓?span>3</span>涓?span>INSERT</span>璇彞鍦?span>user</span>琛ㄤ腑鍔犲叆鏉$洰錛屽厑璁哥敤鎴?span>custom</span>浠庡悇縐嶄富鏈虹敤緇欏畾鐨勫瘑鐮佽繘琛岃繛鎺ワ紝浣嗕笉鎺堜簣鍏ㄥ眬鏉冮檺<span>(</span>鎵鏈夋潈闄愯緗負(fù) 榛樿鍊?span>'N'</span><span>)</span>銆傚悗闈?span>3</span>涓?span>INSERT</span>璇彞鍦?span>user</span>琛ㄤ腑鍔犲叆鏉$洰錛屼負(fù)<span>custom</span>鎺堜簣<span>bankaccount</span>銆?span>expenses</span>鍜?span>customer</span>鏁版嵁搴撴潈闄愶紝浣嗗彧鑳戒粠鍚堥傜殑涓繪満璁塊棶銆?span>閫氬父鑻ョ洿鎺ヤ慨鏀?鎺堟潈琛紝鍒欏簲鍛婅瘔鏈嶅姟鍣ㄧ敤</span><span>FLUSH PRIVILEGES</span><span>閲嶈澆鎺堟潈琛紝浣挎潈闄愭洿鏀圭敓鏁堛?/span></p> <p><span>濡傛灉浣犳兂瑕佽鏌愪釜鐢ㄦ埛浠庣粰瀹氬煙鐨勬墍鏈夋満鍣ㄨ闂?span>(</span>渚嬪錛?/span><span>mydomain.com</span><span>)</span><span>錛屼綘鍙互鍦ㄨ處鎴峰悕鐨勪富鏈洪儴鍒嗕嬌鐢ㄥ惈‘</span><span>%</span><span>’閫氶厤絎︾殑</span><span>GRANT</span><span>璇彞錛?/span></p> <pre><span>mysql> </span><span><strong><span>GRANT ...</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>ON *.*</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>TO 'myname'@'%.mydomain.com'</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>IDENTIFIED BY 'mypass';</span></strong></span></pre> <p>瑕佹兂閫氳繃鐩存帴淇敼鎺堟潈琛ㄦ潵瀹炵幇錛?/p> <pre><span>mysql> </span><span><strong><span>INSERT INTO user (Host,User,Password,...)</span></strong></span></pre> <pre><span>    ->     </span><span><strong><span>VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...);</span></strong></span></pre> <p><span>mysql> </span><span><strong><span>FLUSH PRIVILEGES;</span></strong></span></p> <img src ="http://www.tkk7.com/Javawind/aggbug/159615.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/Javawind/" target="_blank">kooyee</a> 2007-11-10 21:00 <a href="http://www.tkk7.com/Javawind/archive/2007/11/10/159615.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://ytsp88.com" target="_blank">国产免费观看青青草原网站</a>| <a href="http://57gt.com" target="_blank">国产精品色午夜视频免费看</a>| <a href="http://hn-hshb.com" target="_blank">国产成人免费网站</a>| <a href="http://426366.com" target="_blank">国产免费AV片无码永久免费</a>| <a href="http://yjjinfeng.com" target="_blank">亚洲中文无韩国r级电影</a>| <a href="http://dqmovie.com" target="_blank">亚洲AV无码专区国产乱码电影</a>| <a href="http://dasheng178.com" target="_blank">亚洲网站在线播放</a>| <a href="http://wwwtoutoulu.com" target="_blank">亚洲精品蜜夜内射</a>| <a href="http://gttest5.com" target="_blank">久久er国产精品免费观看8</a>| <a href="http://chaikexin.com" target="_blank">久久午夜羞羞影院免费观看</a>| <a href="http://anyliz.com" target="_blank">成年美女黄网站18禁免费</a>| <a href="http://mmstom.com" target="_blank">亚洲国产成人精品91久久久</a>| <a href="http://91haikala.com" target="_blank">久久精品亚洲日本佐佐木明希</a>| <a href="http://sznsfe.com" target="_blank">亚洲最大成人网色香蕉</a>| <a href="http://lanchenews.com" target="_blank">免费播放国产性色生活片</a>| <a href="http://s88s88.com" target="_blank">亚洲免费视频网站</a>| <a href="http://js-jiarui.com" target="_blank">永久免费视频v片www</a>| <a href="http://732r.com" target="_blank">亚洲成色在线综合网站</a>| <a href="http://caoliusq1024.com" target="_blank">亚洲男人天堂2022</a>| <a href="http://fenglibin.com" target="_blank">国产精品hd免费观看</a>| <a href="http://sdhuamo.com" target="_blank">成年人视频免费在线观看</a>| <a href="http://doubaye.com" target="_blank">亚洲国产天堂久久久久久</a>| <a href="http://www026qqcom.com" target="_blank">久久久久久久亚洲Av无码</a>| <a href="http://tzkanglong.com" target="_blank">亚洲av无码一区二区三区在线播放 </a>| <a href="http://nuosheying.com" target="_blank">热99re久久精品精品免费</a>| <a href="http://appmofun.com" target="_blank">中文字幕在线亚洲精品</a>| <a href="http://wwwp784.com" target="_blank">亚洲AV无码乱码麻豆精品国产</a>| <a href="http://778002.com" target="_blank">羞羞视频在线观看免费</a>| <a href="http://littlevv.com" target="_blank">国产精品成人观看视频免费</a>| <a href="http://88ww99.com" target="_blank">亚洲另类激情专区小说图片</a>| <a href="http://znboxcdn304.com" target="_blank">亚洲黄色网址大全</a>| <a href="http://igdytt.com" target="_blank">一级毛片免费播放试看60分钟</a>| <a href="http://hetaoqpj.com" target="_blank">91手机看片国产永久免费</a>| <a href="http://xiaojiejieav.com" target="_blank">亚洲伊人久久综合影院</a>| <a href="http://jpvv8.com" target="_blank">亚洲人成网站色在线观看</a>| <a href="http://hylaowu.com" target="_blank">中文字幕手机在线免费看电影</a>| <a href="http://linmh.com" target="_blank">西西大胆无码视频免费</a>| <a href="http://2xpp.com" target="_blank">国产成人无码综合亚洲日韩</a>| <a href="http://400209.com" target="_blank">亚洲av无码专区国产不乱码 </a>| <a href="http://ww99w.com" target="_blank">国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 </a>| <a href="http://dyk7.com" target="_blank">亚洲∧v久久久无码精品</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>