Source code editor
What Is Ajax
↑
The programs in this section are used when installing or upgrading MySQL.
comp_err creates the
errmsg.sys
file that is used by
mysqld to determine the error messages to
display for different error codes.
comp_err normally is run automatically
when MySQL is built. It compiles the
errmsg.sys
file from the plaintext file
located at sql/share/errmsg.txt
in
MySQL source distributions.
comp_err also generates
mysqld_error.h
,
mysqld_ername.h
, and
sql_state.h
header files.
For more information about how error messages are defined, see the MySQL Internals Manual.
Invoke comp_err like this:
shell> comp_err [options
]
comp_err understands the options described in the following list.
Display a help message and exit.
The character set directory. The default is
../sql/share/charsets
.
--debug=
debug_options
,
-# debug_options
Write a debugging log. The
debug_options
string often is
'd:t:O,
.
The default is
file_name
''d:t:O,/tmp/comp_err.trace'
.
Print some debugging information when the program exits.
--header_file=
file_name
,
-H file_name
The name of the error header file. The default is
mysqld_error.h
.
--in_file=
file_name
,
-F file_name
The name of the input file. The default is
../sql/share/errmsg.txt
.
--name_file=
file_name
,
-N file_name
The name of the error name file. The default is
mysqld_ername.h
.
The name of the output base directory. The default is
../sql/share/
.
--out_file=
file_name
,
-O file_name
The name of the output file. The default is
errmsg.sys
.
--statefile=
file_name
,
-S file_name
The name for the SQLSTATE header file. The default is
sql_state.h
.
Display version information and exit.
This script is used on Windows after building a MySQL distribution from source to create executable programs. It packages the binaries and support files into a ZIP archive that can be unpacked at the location where you want to install MySQL.
make_win_bin_dist is a shell script, so you must have Cygwin installed to use it.
This program's use is subject to change. Currently, you invoke it as follows from the root directory of your source distribution:
shell> make_win_bin_dist [options
] package_basename
[copy_def
...]
The package_basename
argument
provides the basename for the resulting ZIP archive. This
name will be the name of the directory that results from
unpacking the archive.
Because you might want to include files of directories from
other builds, you can instruct this script do copy them in
for you, via copy_def
arguments,
which of which is of the form
relative_dest_name
=source_name
.
Example:
bin/mysqld-max.exe=../my-max-build/sql/release/mysqld.exe
If you specify a directory, the entire directory will be copied.
make_win_bin_dist understands the following options:
Pack the debug binaries and produce an error if they were not built.
Pack the embedded server and produce an error if it was not built. The default is to pack it if it was built.
Add a suffix to the basename of the
mysql binary. For example, a suffix
of -abc
produces a binary named
mysqld-abc.exe.
Don't pack the debug binaries even if they were built.
Don't pack the embedded server even if it was built.
Use this option when the target for this build was
Debug
, and you just want to replace
the normal binaries with debug versions (that is, do not
use separate debug
directories).
make_win_src_distribution creates a Windows source package to be used on Windows systems. It is used after you configure and build the source distribution on a Unix or Unix-like system so that you have a server binary to work with. (See the instructions at Section 2.4.14.6.4, “Creating a Windows Source Package from the Latest Development Source”.)
Invoke make_win_src_distribution like this from the top-level directory of a MySQL source distribution:
shell> make_win_src_distribution [options
]
make_win_src_distribution understands the following options:
--help
Display a help message and exit.
--debug
Print information about script operations; do not create a package.
--tmp
Specify the temporary location.
--suffix
The suffix name for the package.
--dirname
Directory name to copy files (intermediate).
--silent
Do not print verbose list of files processed.
--tar
Create a tar.gz
package instead of
a .zip
package.
By default, make_win_src_distribution
creates a Zip-format archive with the name
mysql-
,
where VERSION
-win-src.zipVERSION
represents the
version of your MySQL source tree.
Some releases of MySQL introduce changes to the structure of
the system tables in the mysql
database
to add new privileges or support new features. When you
update to a new version of MySQL, you should update your
system tables as well to make sure that their structure is
up to date. Otherwise, there might be capabilities that you
cannot take advantage of. First, make a backup of your
mysql
database, and then use the
following procedure.
Note: As of MySQL 5.0.19, mysql_fix_privilege_tables is superseded by mysql_upgrade, which should be used instead. See Section 5.5.8, “mysql_upgrade — Check Tables for MySQL Upgrade”.
On Unix or Unix-like systems, update the system tables by running the mysql_fix_privilege_tables script:
shell> mysql_fix_privilege_tables
You must run this script while the server is running. It
attempts to connect to the server running on the local host
as root
. If your root
account requires a password, indicate the password on the
command line like this:
shell> mysql_fix_privilege_tables --password=root_password
The mysql_fix_privilege_tables script
performs any actions necessary to convert your system tables
to the current format. You might see some Duplicate
column name
warnings as it runs; you can ignore
them.
After running the script, stop the server and restart it.
On Windows systems, MySQL distributions include a
mysql_fix_privilege_tables.sql
SQL
script that you can run using the mysql
client. For example, if your MySQL installation is located
at C:\Program Files\MySQL\MySQL Server
5.0
, the commands look like this:
C:\>cd "C:\Program Files\MySQL\MySQL Server 5.0"
C:\>bin\mysql -u root -p mysql
mysql>SOURCE scripts/mysql_fix_privilege_tables.sql
The mysql command will prompt you for the
root
password; enter it when prompted.
If your installation is located in some other directory, adjust the pathnames appropriately.
As with the Unix procedure, you might see some
Duplicate column name
warnings as
mysql processes the statements in the
mysql_fix_privilege_tables.sql
script;
you can ignore them.
After running the script, stop the server and restart it.
mysql_install_db initializes the MySQL
data directory and creates the system tables that it
contains, if they do not exist. Because the MySQL server,
mysqld, needs to access the data
directory when it runs later, you should either run
mysql_install_db from the same account
that will be used for running mysqld or
run it as root
and use the
--user
option to indicate the username that
mysqld will run as.
To invoke mysql_install_db, use the following syntax:
shell> mysql_install_db [options
]
mysql_install_db needs to invoke
mysqld with the
--bootstrap
and
--skip-grant-tables
options (see
Section 2.4.14.2, “Typical configure Options”). If MySQL was
configured with the --disable-grant-options
option, --bootstrap
and
--skip-grant-tables
will be disabled. To
handle this, set the MYSQLD_BOOTSTRAP
environment variable to the full pathname of a server that
has all options enabled. mysql_install_db
will use that server.
mysql_install_db supports the following options:
--basedir=
path
The path to the MySQL installation directory.
--force
Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses.
--datadir=
,
path
--ldata=
path
The path to the MySQL data directory.
--rpm
For internal use. This option is used by RPM files during the MySQL installation process.
--skip-name-resolve
Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work.
--srcdir=
path
For internal use. The directory under which mysql_install_db looks for support files such as the error message file and the file for populating the help tables. This option was added in MySQL 5.0.32.
--user=
user_name
The login username to use for running
mysqld. Files and directories created
by mysqld will be owned by this user.
You must be root
to use this option.
By default, mysqld runs using your
current login name and files and directories that it
creates will be owned by you.
--verbose
Verbose mode. Print more information about what the program does.
--windows
For internal use. This option is used for creating Windows distributions.
This program enables you to improve the security of your MySQL installation in the following ways:
You can set a password for root
accounts.
You can remove root
accounts that are
accessible from outside the local host.
You can remove anonymous-user accounts.
You can remove the test
database,
which by default can be accessed by anonymous users.
Invoke mysql_secure_installation without arguments:
shell> mysql_secure_installation
The script will prompt you to determine which actions to perform.
The mysql_tzinfo_to_sql program loads the
time zone tables in the mysql
database.
It is used on systems that have a
zoneinfo database (the set of files
describing time zones). Examples of such systems are Linux,
FreeBSD, Sun Solaris, and Mac OS X. One likely location for
these files is the /usr/share/zoneinfo
directory. If your system does not have a zoneinfo database,
you can use the downloadable package described in
Section 5.10.8, “MySQL Server Time Zone Support”.
mysql_tzinfo_to_sql can be invoked several ways:
shell>mysql_tzinfo_to_sql
shell>tz_dir
mysql_tzinfo_to_sql
shell>tz_file tz_name
mysql_tzinfo_to_sql --leap
tz_file
For the first invocation syntax, pass the zoneinfo directory pathname to mysql_tzinfo_to_sql and send the output into the mysql program. For example:
shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
mysql_tzinfo_to_sql reads your system's time zone files and generates SQL statements from them. mysql processes those statements to load the time zone tables.
The second syntax causes
mysql_tzinfo_to_sql to load a single time
zone file tz_file
that
corresponds to a time zone name
tz_name
:
shell> mysql_tzinfo_to_sql tz_file
tz_name
| mysql -u root mysql
If your time zone needs to account for leap seconds, invoke
mysql_tzinfo_to_sql using the third
syntax, which initializes the leap second information.
tz_file
is the name of your time
zone file:
shell> mysql_tzinfo_to_sql --leap tz_file
| mysql -u root mysql
mysql_upgrade should be executed each time you upgrade MySQL. It checks all tables in all databases for incompatibilities with the current version of MySQL Server. If a table is found to have a possible incompatibility, it is checked. If any problems are found, the table is repaired. mysql_upgrade also upgrades the system tables so that you can take advantage of new privileges or capabilities that might have been added.
All checked and repaired tables are marked with the current MySQL version number. This ensures that next time you run mysql_upgrade with the same version of the server, it can tell whether there is any need to check or repair the table again.
mysql_upgrade also saves the MySQL
version number in a file named
mysql_upgrade.info
in the data
directory. This is used to quickly check if all tables have
been checked for this release so that table-checking can be
skipped. To ignore this file, use the
--force
option.
To check and repair tables and to upgrade the system tables, mysql_upgrade executes the following commands:
mysqlcheck --check-upgrade --all-databases --auto-repair mysql_fix_privilege_tables
mysql_upgrade supersedes the older mysql_fix_privilege_tables script. In MySQL 5.0.19, mysql_upgrade was added as a shell script and worked only for Unix systems. As of MySQL 5.0.25, mysql_upgrade is an executable binary and is available on all systems. On systems older than those supporting mysql_upgrade, you can execute the mysqlcheck command manually, and then upgrade your system tables as described in Section 5.5.4, “mysql_fix_privilege_tables — Upgrade MySQL System Tables”.
For details about what is checked, see the description of
the FOR UPGRADE
option of the
CHECK TABLE
statement (see
Section 13.5.2.3, “CHECK TABLE
Syntax”).
To use mysql_upgrade, make sure that the server is running, and then invoke it like this:
shell> mysql_upgrade [options
]
mysql_upgrade reads options from the
command line and from the [mysql_upgrade]
group in option files. It supports the following options:
Display a short help message and exit.
The path to the MySQL installation directory.
The path to the data directory.
Force execution of mysqlcheck even if
mysql_upgrade has already been
executed for the current version of MySQL. (In other
words, this option causes the
mysql_upgrade.info
file to be
ignored.)
--user=
,
user_name
-u
user_name
The MySQL username to use when connecting to the server.
The default username is root
.
Verbose mode. Print more information about what the program does.
Other options are passed to mysqlcheck
and to mysql_fix_privilege_tables. For
example, it might be necessary to specify the
--password[=
option.
password
]