Mysql: Grant
Mysql: Grant
If you have assigned a password to the root account, you will also need to supply a
--password or -p option, both for this mysql command and for those later in this section.
After connecting to the server as root, you can add new accounts. The following statements
use GRANT to set up four new accounts:
Two of the accounts have a user name of monty and a password of some_pass. Both
accounts are superuser accounts with full privileges to do anything. The
'monty'@'localhost' account can be used only when connecting from the local
host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be
used to connect from any host.
It is necessary to have both accounts for monty to be able to connect from anywhere
as monty. Without the localhost account, the anonymous-user account for
localhost that is created by mysql_install_db would take precedence when monty
connects from the local host. As a result, monty would be treated as an anonymous
user. The reason for this is that the anonymous-user account has a more specific Host
column value than the 'monty'@'%' account and thus comes earlier in the user table
sort order. (user table sorting is discussed in Section 5.4.4, “Access Control, Stage 1:
Connection Verification”.)
The 'admin'@'localhost' account has no password. This account can be used only
by admin to connect from the local host. It is granted the RELOAD and PROCESS
administrative privileges. These privileges enable the admin user to execute the
mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands,
as well as mysqladmin processlist . No privileges are granted for accessing any
databases. You could add such privileges later by issuing other GRANT statements.
The 'dummy'@'localhost' account has no password. This account can be used only
to connect from the local host. No privileges are granted. It is assumed that you will
grant specific privileges to the account later.
The statements that create accounts with no password will fail if the NO_AUTO_CREATE_USER
SQL mode is enabled. To deal with this, use an IDENTIFIED BY clause that specifies a
nonempty password.
To check the privileges for an account, use SHOW GRANTS:
JAR Files
This topic describes how JAR files are used in the JavaHelp system.
After you create your help information, you will usually encapsulate it into a single
file and compress it for delivery to your users. The JavaHelp system uses the JAR
(Java ARchive) format for encapsulation and compression. The JAR file format is
based on the popular ZIP file format. The JavaHelp system automatically extracts
information from the JAR file when it is required.
Until support is available from GUI-base help authoring tools, the jar command
(located in the J2SE
bin folder) must be used from a command-line prompt to create, read, and extract data
from JAR files.
To create a JAR file from your help files, make the top level help folder the current
folder. The jar command descends recursively through the different directories and
copies all of the files to the JAR file.
Use the following steps to create a JAR file named my_help.jar from the hierarchy
example above:
1. C:\> cd ...\help (where "..." is the path above the \help folder)
2. C:...\help> jar -cvf my_help.jar *
The jar -cvf command copies all the files in the \help folder and in all folders
hierarchically beneath it into a JAR file named my_help.jar. As the command
creates the JAR file, it reports its progress with output like the following:
adding: my_helpset.hs (in=5757) (out=2216) (deflated 61%)
This indicates that the file my_helpset.hs was added to the JAR file and compressed
61% (from 5272 bytes to 2150 bytes).
When you create a JAR file, the jar command automatically creates a manifest file
for you. The manifest file consists of a list of files present within the archive itself.
Note that it is not necessary to extract files from the JAR file to use them with the
JavaHelp system. The JavaHelp system reads files directly from the JAR file as they
are required.
The Java 2 SDK implements a protocol for referring explicitly to files within JAR
TM
jar:<url>!/{entry}
The jar: protocol can be used to refer to entries within JAR files, the entire JAR file,
or a directory as base URLs (JAR directory).
Examples:
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
A JAR file:
jar:file://www.foo.com/bar/baz.jar!/
A JAR directory:
jar:file://www.foo.com/bar/baz.jar!/COM/foo/
Index File
The index file describes to the index navigator the content and layout of the index.
The format of the index file is based on the World Wide Web Consortium Extended
Markup Language (XML). The following is a very small example of an index file:
<!DOCTYPE index
PUBLIC
"http://java.sun.com/products/javahelp/index_2_0.dtd">
<index version="2.0">
target="prof.profile" />
target="proj.importdirectory" />
</indexitem>
presentationname="mainsw">
<indexitem text="editing in content page"
target="applet_editing">
target="applet_insert">
</indexitem>
</index>
<index> Defines the index. It can contains <indexitem> tags and the
following optional attributes.
Some examples:
xml:lang="de"
xml:lang="en"
xml:lang="en-US"
version="1.0"|"2.0" Version of JavaHelp software.
.
<indexitem> Defines an index entry. Nesting entry1 within entry2 defines entry2
to be hierarchically contained within entry1. Uses the following
attributes:
Some examples:
xml:lang="de"
xml:lang="en"
xml:lang="en-US"
text="string" Specifies the text that displays in the index.
target="string" (optional) Specifies the map ID of the topic
that displays when the entry is chosen by the
user. IDs are defined (associated with a URL)
in the map file. If this attribute is not used, the
index entry does not link to a topic (probably
because it's being used to group sub-entries).
mergetype="class" (optional) The path to a valid merge class for
the view. The default merge type for an index
is javax.help.AppendMerge.
javax.help.UniteAppendMerge
javax.help.SortMerge
javax.help.AppendMerge
javax.help.NoMerge
Synopsis
Description
Options
Command Line Argument Files
Examples
See Also
SYNOPSIS
Create jar file
jar c[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar c[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar c[v0M] [-C dir] inputfiles [-Joption]
jar c[v0]m manifest [-C dir] inputfiles [-Joption]
Update jar file
jar u[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar u[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar u[v0M] [-C dir] inputfiles [-Joption]
jar u[v0]m manifest [-C dir] inputfiles [-Joption]
Extract jar file
jar x[v]f jarfile [inputfiles] [-Joption]
jar x[v] [inputfiles] [-Joption]
List table of contents of jar file
jar t[v]f jarfile [inputfiles] [-Joption]
jar t[v] [inputfiles] [-Joption]
Add index to jar file
jar i jarfile [-Joption]
where:
cuxtiv0Mmf
Options that control the jar command.
jarfile
Jar file to be created (c), updated (u), extracted (x), or have its table of
contents viewed (t). The f option and filename jarfile are a pair -- if
either is present, they must both appear. Note that omitting f and
jarfile accepts a "jar file" from standard input (for x and t) or sends the
"jar file" to standard output (for c and u).
inputfiles
Files or directories, separated by spaces, to be combined into jarfile
(for c and u), or to be extracted (for x) or listed (for t) from jarfile. All
directories are processed recursively. The files are compressed unless
option O (zero) is used.
manifest
Pre-existing manifest file whose name: value pairs are to be included
in MANIFEST.MF in the jar file. The m option and filename
manifesfile are a pair -- if either is present, they must both appear. The
letters m and f must appear in the same order that manifest and jarfile
appear.
-C dir
Temporarily changes directories to dir while processing the following
inputfiles argument. Multiple -C dir inputfiles sets are allowed.
-Joption
Option to be passed into the Java runtime environment. (There must be
no space between -J and option).
DESCRIPTION
The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose
archiving and compression tool, based on ZIP and the ZLIB compression format. However,
jar was designed mainly to facilitate the packaging of java applets or applications into a
single archive. When the components of an applet or application (.class files, images and
sounds) are combined into a single archive, they may be downloaded by a java agent (like a
browser) in a single HTTP transaction, rather than requiring a new connection for each piece.
This dramatically improves download times. jar also compresses files and so further
improves download time. In addition, it allows individual entries in a file to be signed by the
applet author so that their origin can be authenticated. The syntax for the jar tool is almost
identical to the syntax for the tar command. A jar archive can be use as a class path entry,
whether it is compressed or not.
If you have a pre-existing manifest file whose name: value pairs you want the jar tool to
include for the new jar archive, you can specify it using the m option:
% jar xf myFile.jar
To extract only certain files from a jar file, supply their filenames:
% jar i main.jar
In this example, an INDEX.LIST file is inserted into the META-INF directory of main.jar.
The application class loader will use the information stored in this file for efficient class
loading. Refer to the JarIndex specification for details about how location information is
stored in the index file.
A standard way to copy directories is to first compress files in dir1 to standard out, then
extract from standard in to dir2 (omitting f from both jar commands):
Examples of using the jar tool to operate on jar files and jar file manifests are provided below
and in the Jar trail of the Java Tutorial.
OPTIONS
c
Creates a new archive to file named jarfile (if f is specified) or to standard
output (if f and jarfile are omitted). Add to it the files and directories specified
by inputfiles.
u
Updates an existing file jarfile (when f is specified) by adding to it files and
directories specified by inputfiles. For example:
jar uf foo.jar foo.class
would add the file foo.class to the existing jar file foo.jar. The u option
can also update the manifest entry, as given by this example:
jar umf manifest foo.jar
updates the foo.jar manifest with the name: value pairs in manifest.
x
Extracts files and directories from jarfile (if f is specified) or standard input (if
f and jarfile are omitted). If inputfiles is specified, only those specified files
and directories are extracted. Otherwise, all files and directories are extracted.
t
Lists the table of contents from jarfile (if f is specified) or standard input (if f
and jarfile are omitted). If inputfiles is specified, only those specified files and
directories are listed. Otherwise, all files and directories are listed.
i
Generate index information for the specified jarfile and its dependent jar files.
For example:
jar i foo.jar
would generate an INDEX.LIST file in foo.jar which contains location
information for each package in foo.jar and all the jar files specified in the
Class-Path attribute of foo.jar. See the index example.
f
Specifies the file jarfile to be created (c), updated (u), extracted (x), indexed
(i), or viewed (t). The f option and filename jarfile are a pair -- if present,
they must both appear. Omitting f and jarfile accepts a "jar file" from standard
input (for x and t) or sends the "jar file" to standard output (for c and u).
v
Generates verbose output to standard output. Examples shown below.
0
(zero) Store without using ZIP compression.
M
Do not create a manifest file entry (for c and u), or delete a manifest file entry
if one exists (for u).
m
Includes name: value attribute pairs from the specified manifest file manifest
in the file at META-INF/MANIFEST.MF. A name: value pair is added unless one
already exists with the same name, in which case its value is updated.
On the command line, the letters m and f must appear in the same order that
manifest and jarfile appear. Example use:
An argument file can include options and filenames. The arguments within a file can be
space-separated or newline-separated. Filenames within an argument file are relative to the
current directory, not the location of the argument file. Wildcards (*) that might otherwise be
expanded by the operating system shell are not expanded. Use of the '@' character to
recursively interpret files is not supported. The -J options are not supported because they are
passed to the launcher, which does not support argument files.
When executing jar, pass in the path and name of each argument file with the '@' leading
character. When jar encounters an argument beginning with the character `@', it expands the
contents of that file into the argument list.
For example, you could use a single argument file named "classes.list" to hold the names
of the files:
EXAMPLES
To add all the files in a particular directory to an archive (overwriting contents if the archive
already exists). Enumerating verbosely (with the "v" option) will tell you more information
about the files in the archive, such as their size and last modified date.
% ls
1.au Animator.class monkey.jpg
2.au Wave.class spacemusic.au
3.au at_work.gif
% ls -F
audio/ bundle.jar classes/ images/
To see the entry names in the jarfile, use the "t" option:
% jar tf bundle.jar
META-INF/
META-INF/MANIFEST.MF
audio/1.au
audio/2.au
audio/3.au
audio/spacemusic.au
classes/Animator.class
classes/Wave.class
images/monkey.jpg
images/at_work.gif
To add an index file to the jar file for speeding up class loading, use the "i" option.
Let's say you split the inter-dependent classes for a stock trade application, into three jar files:
main.jar, buy.jar, and sell.jar. If you specify the Class-path attribute in the main.jar
manifest as:
Class-Path: buy.jar sell.jar
then you can use the i option to speed up your application's class loading time:
% jar i main.jar
An INDEX.LIST file is inserted to the META-INF directory which will enable the
application class loader to download the specified jar files when it is searching for classes or
resources.
Jar is:
Jar consists of a zip archive, as defined by PKWARE, containing a manifest file and
potentially signature files, as defined in the Jar File Specification.
Th ARCHIVE attribute describes one or more Jar files containing classes and other resources
that will be "preloaded". The classes are loaded using an instance of an AppletClassLoader
with the given CODEBASE. It takes the form archive = archiveList. The archives in
archiveList are separated by ",".
Once the archive file is identified, it is downloaded and separated into its components. During
the execution of the applet, when a new class, image or audio clip is requested by the applet,
it is searched for first in the archives associated with the applet. If the file is not found
amongst the archives that were downloaded, it is searched for on the applet's server, relative
to the CODEBASE (that is, it is searched for as in JDK1.0.2).
The archive tag may specify multiple Jar files. Each Jar file must be separated by ","
(comma). Each file is downloaded in turn:
<applet code=Animator.class
archive="classes.jar , images.jar , sounds.jar"
width=460 height=160>
<param name=foo value="bar">
</applet>
There can be any amount of white space between entries within the archive parameter. In
addition, the archive tag itself is case-insensitive; it can be lower-case, upper-case, or any
combination of lower- and upper-case letters, such as ArCHiVe.
The Solaris 2.6 kernel has already been extended to recognize the special "magic" number
that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native
Solaris executable. A application packaged in a Jar file can thus be executed directly from the
command line or by clicking an icon on the CDE desktop.