~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to INSTALL-SOURCE

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-21 15:31:05 UTC
  • mfrom: (1.1.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20100621153105-pbbz3t6nyrf9t2zq
Tags: upstream-5.1.48
ImportĀ upstreamĀ versionĀ 5.1.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
   and about issues that you should consider before upgrading.
10
10
 
11
11
   If you are interested in migrating to MySQL from another database
12
 
   system, you may wish to read Section A.8, "MySQL 5.1 FAQ ---
 
12
   system, you may wish to read Section A.8, "MySQL 5.1 FAQ:
13
13
   Migration," which contains answers to some common questions
14
14
   concerning migration issues.
15
15
 
400
400
 
401
401
     * Enterprise Server releases are meant to appear every 18
402
402
       months, supplemented by quarterly service packs and monthly
403
 
       rapid updates. Community Server releases are meant to appear
404
 
       2-3 times per year.
 
403
       rapid updates. Community Server releases are meant to appear 2
 
404
       to 3 times per year.
405
405
 
406
406
     * Releases are issued within each series. For each release, the
407
407
       last number in the version is one more than the previous
467
467
shell> md5sum package_name
468
468
 
469
469
   Example:
470
 
shell> md5sum mysql-standard-5.1.48-linux-i686.tar.gz
471
 
aaab65abbec64d5e907dcd41b8699945  mysql-standard-5.1.48-linux-i686.ta
 
470
shell> md5sum mysql-standard-5.1.49-linux-i686.tar.gz
 
471
aaab65abbec64d5e907dcd41b8699945  mysql-standard-5.1.49-linux-i686.ta
472
472
r.gz
473
473
 
474
474
   You should verify that the resulting checksum (the string of
586
586
   signature, which also is available from the download page. The
587
587
   signature file has the same name as the distribution file with an
588
588
   .asc extension, as shown by the examples in the following table.
589
 
   Distribution file mysql-standard-5.1.48-linux-i686.tar.gz
590
 
   Signature file    mysql-standard-5.1.48-linux-i686.tar.gz.asc
 
589
   Distribution file mysql-standard-5.1.49-linux-i686.tar.gz
 
590
   Signature file    mysql-standard-5.1.49-linux-i686.tar.gz.asc
591
591
 
592
592
   Make sure that both files are stored in the same directory and
593
593
   then run the following command to verify the signature for the
595
595
shell> gpg --verify package_name.asc
596
596
 
597
597
   Example:
598
 
shell> gpg --verify mysql-standard-5.1.48-linux-i686.tar.gz.asc
 
598
shell> gpg --verify mysql-standard-5.1.49-linux-i686.tar.gz.asc
599
599
gpg: Signature made Tue 12 Jul 2005 23:35:41 EST using DSA key ID 507
600
600
2E1F5
601
601
gpg: Good signature from "MySQL Package signing key (www.mysql.com) <
615
615
shell> rpm --checksig package_name.rpm
616
616
 
617
617
   Example:
618
 
shell> rpm --checksig MySQL-server-5.1.48-0.glibc23.i386.rpm
619
 
MySQL-server-5.1.48-0.glibc23.i386.rpm: md5 gpg OK
 
618
shell> rpm --checksig MySQL-server-5.1.49-0.glibc23.i386.rpm
 
619
MySQL-server-5.1.49-0.glibc23.i386.rpm: md5 gpg OK
620
620
 
621
621
Note
622
622
 
705
705
   distribution by executing the scripts/make_binary_distribution
706
706
   script from the top directory of the source distribution.
707
707
 
 
708
2.1.6. Compiler-Specific Build Characteristics
 
709
 
 
710
   In some cases, the compiler used to build MySQL affects the
 
711
   features available for use. The notes in this section apply for
 
712
   binary distributions provided by Oracle Corporation or that you
 
713
   compile yourself from source.
 
714
 
 
715
   icc (Intel C++ Compiler) Builds
 
716
 
 
717
   A server built with icc has these characteristics:
 
718
 
 
719
     * SSL support is not included.
 
720
 
 
721
     * InnoDB Plugin is not included.
 
722
 
708
723
2.2. Installing MySQL from Generic Binaries on Unix/Linux
709
724
 
710
725
   This section covers the installation of MySQL binary distributions
727
742
 
728
743
   MySQL tar file binary distributions have names of the form
729
744
   mysql-VERSION-OS.tar.gz, where VERSION is a number (for example,
730
 
   5.1.48), and OS indicates the type of operating system for which
 
745
   5.1.49), and OS indicates the type of operating system for which
731
746
   the distribution is intended (for example, pc-linux-i686).
732
747
 
733
748
   In addition to these generic packages, we also offer binaries in
848
863
       MySQL data directory and initialize the grant tables:
849
864
shell> scripts/mysql_install_db --user=mysql
850
865
       If you run the command as root, include the --user option as
851
 
       shown. If you run the command while logged in as that user,
852
 
       you can omit the --user option.
 
866
       shown. If you run the while logged in as that user, you can
 
867
       omit the --user option.
853
868
       The command should create the data directory and its contents
854
869
       with mysql as the owner.
855
870
       After creating or updating the grant tables, you need to
862
877
shell> chown -R root .
863
878
shell> chown -R mysql data
864
879
 
865
 
    9. If you want MySQL to start automatically when you boot your
 
880
    9. If the plugin directory is writable by the server, it may be
 
881
       possible for a user to write executable code to a file in the
 
882
       directory using SELECT ... INTO DUMPFILE. This can be
 
883
       prevented by making plugin_dir read only to the server or by
 
884
       setting --secure-file-priv to a directory where SELECT writes
 
885
       can be made safely.
 
886
   10. If you want MySQL to start automatically when you boot your
866
887
       machine, you can copy support-files/mysql.server to the
867
888
       location where your system has its startup files. More
868
889
       information can be found in the support-files/mysql.server
869
890
       script itself and in Section 2.13.1.2, "Starting and Stopping
870
891
       MySQL Automatically."
871
 
   10. You can set up new accounts using the bin/mysql_setpermission
 
892
   11. You can set up new accounts using the bin/mysql_setpermission
872
893
       script if you install the DBI and DBD::mysql Perl modules. See
873
894
       Section 4.6.14, "mysql_setpermission --- Interactively Set
874
895
       Permissions in Grant Tables." For Perl module installation
875
896
       instructions, see Section 2.15, "Perl Installation Notes."
876
 
   11. If you would like to use mysqlaccess and have the MySQL
 
897
   12. If you would like to use mysqlaccess and have the MySQL
877
898
       distribution in some nonstandard location, you must change the
878
899
       location where mysqlaccess expects to find the mysql client.
879
900
       Edit the bin/mysqlaccess script at approximately line 18.
921
942
 
922
943
   MySQL source distributions are provided as compressed tar archives
923
944
   and have names of the form mysql-VERSION.tar.gz, where VERSION is
924
 
   a number like 5.1.48.
 
945
   a number like 5.1.49.
925
946
 
926
947
   You need the following tools to build and install MySQL from
927
948
   source:
1094
1115
       root in the installation directory:
1095
1116
shell> chown -R root .
1096
1117
shell> chown -R mysql var
1097
 
   13. If you want MySQL to start automatically when you boot your
 
1118
   13. If the plugin directory is writable by the server, it may be
 
1119
       possible for a user to write executable code to a file in the
 
1120
       directory using SELECT ... INTO DUMPFILE. This can be
 
1121
       prevented by making plugin_dir read only to the server or by
 
1122
       setting --secure-file-priv to a directory where SELECT writes
 
1123
       can be made safely.
 
1124
   14. If you want MySQL to start automatically when you boot your
1098
1125
       machine, you can copy support-files/mysql.server to the
1099
1126
       location where your system has its startup files. More
1100
1127
       information can be found in the support-files/mysql.server
1101
1128
       script itself; see also Section 2.13.1.2, "Starting and
1102
1129
       Stopping MySQL Automatically."
1103
 
   14. You can set up new accounts using the bin/mysql_setpermission
 
1130
   15. You can set up new accounts using the bin/mysql_setpermission
1104
1131
       script if you install the DBI and DBD::mysql Perl modules. See
1105
1132
       Section 4.6.14, "mysql_setpermission --- Interactively Set
1106
1133
       Permissions in Grant Tables." For Perl module installation
1327
1354
     * If you want to build the embedded MySQL library (libmysqld.a),
1328
1355
       use the --with-embedded-server option.
1329
1356
 
1330
 
     * If you don't want your log files and database directories
 
1357
     * If you do not want your log files and database directories
1331
1358
       located under /usr/local/var, use a configure command
1332
1359
       something like one of these:
1333
1360
shell> ./configure --prefix=/usr/local/mysql
1369
1396
shell> ./configure --with-client-ldflags=-all-static \
1370
1397
           --with-mysqld-ldflags=-all-static
1371
1398
 
1372
 
     * If you are using gcc and don't have libg++ or libstdc++
 
1399
     * If you are using gcc and do not have libg++ or libstdc++
1373
1400
       installed, you can tell configure to use gcc as your C++
1374
1401
       compiler:
1375
1402
shell> CC=gcc CXX=gcc ./configure
2040
2067
       take advantage of any new capabilities. (Some releases of
2041
2068
       MySQL introduce changes to the structure of the grant tables
2042
2069
       to add new privileges or features.)
 
2070
       mysql_upgrade does not upgrade the contents of the help
 
2071
       tables. For upgrade instructions, see Section 5.1.8,
 
2072
       "Server-Side Help."
2043
2073
 
2044
2074
     * If you run MySQL Server on Windows, see Section 2.5.7,
2045
2075
       "Upgrading MySQL on Windows."
2196
2226
       take advantage of any new capabilities. (Some releases of
2197
2227
       MySQL introduce changes to the structure of the grant tables
2198
2228
       to add new privileges or features.)
 
2229
       mysql_upgrade does not upgrade the contents of the help
 
2230
       tables. For upgrade instructions, see Section 5.1.8,
 
2231
       "Server-Side Help."
2199
2232
 
2200
2233
     * If you run MySQL Server on Windows, see Section 2.5.7,
2201
2234
       "Upgrading MySQL on Windows."
3268
3301
 
3269
3302
     * Large Table Support
3270
3303
       If you need tables with a size larger than 4GB, install MySQL
3271
 
       on an NTFS or newer file system. Don't forget to use MAX_ROWS
 
3304
       on an NTFS or newer file system. Do not forget to use MAX_ROWS
3272
3305
       and AVG_ROW_LENGTH when you create tables. See Section
3273
3306
       12.1.17, "CREATE TABLE Syntax."
3274
3307
 
3383
3416
   Full details on the components are suggested uses are provided
3384
3417
   below for reference:
3385
3418
 
3386
 
     * Windows Essentials --- this package has a file name similar to
3387
 
       mysql-essential-5.1.48-win32.msi and is supplied as a
 
3419
     * Windows Essentials : This package has a file name similar to
 
3420
       mysql-essential-5.1.49-win32.msi and is supplied as a
3388
3421
       Microsoft Installer (MSI) package. The package includes the
3389
3422
       minimum set of files needed to install MySQL on Windows,
3390
3423
       including the MySQL Server Instance Config Wizard. This
3394
3427
       To install using this package, see Section 2.5.3, "Installing
3395
3428
       MySQL with the MSI Package."
3396
3429
 
3397
 
     * Windows MSI Installer (Complete) --- this package has a file
3398
 
       name similar to mysql-5.1.48-win32.zip and contains all files
 
3430
     * Windows MSI Installer (Complete): This package has a file name
 
3431
       similar to mysql-5.1.49-win32.zip and contains all files
3399
3432
       needed for a complete Windows installation, including the
3400
3433
       MySQL Server Instance Config Wizard. This package includes
3401
3434
       optional components such as the embedded server and benchmark
3403
3436
       To install using this package, see Section 2.5.3, "Installing
3404
3437
       MySQL with the MSI Package."
3405
3438
 
3406
 
     * Without installer --- this package has a file name similar to
3407
 
       mysql-noinstall-5.1.48-win32.zip and contains all the files
 
3439
     * Without installer: This package has a file name similar to
 
3440
       mysql-noinstall-5.1.49-win32.zip and contains all the files
3408
3441
       found in the Complete install package, with the exception of
3409
3442
       the MySQL Server Instance Config Wizard. This package does not
3410
3443
       include an automated installer, and must be manually installed
3657
3690
   directory. In a default installation it contains C:\Program
3658
3691
   Files\MySQL\MySQL Server 5.1\. The Version string contains the
3659
3692
   release number. For example, for an installation of MySQL Server
3660
 
   5.1.48, the key contains a value of 5.1.48.
 
3693
   5.1.49, the key contains a value of 5.1.49.
3661
3694
 
3662
3695
   These registry keys are used to help external tools identify the
3663
3696
   installed location of the MySQL server, preventing a complete scan
3870
3903
   Section 2.5.3.1.1, "Downloading and Starting the MySQL
3871
3904
   Installation Wizard." Rather than opening a port, you also have
3872
3905
   the option of adding MySQL as a program that bypasses the Windows
3873
 
   Firewall. One or the other option is sufficient --- you need not
3874
 
   do both. Additionally, when running the MySQL Server Config Wizard
3875
 
   on Windows Vista ensure that you are logged in as a user with
 
3906
   Firewall. One or the other option is sufficient---you need not do
 
3907
   both. Additionally, when running the MySQL Server Config Wizard on
 
3908
   Windows Vista ensure that you are logged in as a user with
3876
3909
   administrative rights.
3877
3910
   MySQL Server Instance Config Wizard
3878
3911
 
4365
4398
 
4366
4399
   When specifying options on the command line, you can enclose the
4367
4400
   entire command-line option and the value you are specifying using
4368
 
   double quotes. This enables you to use spaces in the options. For
4369
 
   example, "-cC:\mysql.ini".
 
4401
   double quotation marks. This enables you to use spaces in the
 
4402
   options. For example, "-cC:\mysql.ini".
4370
4403
 
4371
4404
   The following command installs a MySQL Server 5.1 instance from
4372
4405
   the directory C:\Program Files\MySQL\MySQL Server 5.1 using the
4669
4702
   something like this, which indicates that the server is ready to
4670
4703
   service client connections:
4671
4704
mysqld: ready for connections
4672
 
Version: '5.1.48'  socket: ''  port: 3306
 
4705
Version: '5.1.49'  socket: ''  port: 3306
4673
4706
 
4674
4707
   The server continues to write to the console any further
4675
4708
   diagnostic output it produces. You can open a new console window
5488
5521
Note
5489
5522
 
5490
5523
   To compile from the source code on Windows you must use the
5491
 
   standard source distribution (for example, mysql-5.1.48.tar.gz).
 
5524
   standard source distribution (for example, mysql-5.1.49.tar.gz).
5492
5525
   You build from the same distribution as used to build MySQL on
5493
5526
   Unix, Linux and other platforms. Do not use the Windows Source
5494
5527
   distributions as they do not contain the necessary configuration
5881
5914
   the appropriate entries in /etc/init.d/ to start the server
5882
5915
   automatically at boot time. (This means that if you have performed
5883
5916
   a previous installation and have made changes to its startup
5884
 
   script, you may want to make a copy of the script so that you
5885
 
   don't lose it when you install a newer RPM.) See Section 2.13.1.2,
 
5917
   script, you may want to make a copy of the script so that you do
 
5918
   not lose it when you install a newer RPM.) See Section 2.13.1.2,
5886
5919
   "Starting and Stopping MySQL Automatically," for more information
5887
5920
   on how MySQL can be started automatically on system startup.
5888
5921
 
6426
6459
       your client.
6427
6460
 
6428
6461
   If you have problems with configure trying to link with -lz when
6429
 
   you don't have zlib installed, you have two options:
 
6462
   you do not have zlib installed, you have two options:
6430
6463
 
6431
6464
     * If you want to be able to use the compressed communication
6432
6465
       protocol, you need to get and install zlib from ftp.gnu.org.
6610
6643
 
6611
6644
   You must specify 6 parameters to perform an upgrade:
6612
6645
 
6613
 
     * DIR('/QOpenSys/usr/local/') --- sets the installation location
 
6646
     * DIR('/QOpenSys/usr/local/'): Sets the installation location
6614
6647
       for the MySQL files. The directory will be created if it does
6615
6648
       not already exist. This is the directory that the MySQL server
6616
6649
       will be installed into, inside a directory with a name
6620
6653
       symbolic link to this directory will be created in
6621
6654
       /QOpenSys/usr/local/mysql.
6622
6655
 
6623
 
     * DATADIR('/QOpenSys/mysql/data') --- sets the location of the
 
6656
     * DATADIR('/QOpenSys/mysql/data'): Sets the location of the
6624
6657
       directory that will be upgraded.
6625
6658
 
6626
 
     * USRPRF('MYSQL') --- sets the user profile that will own the
6627
 
       files that are installed. The profile will be created if it
6628
 
       does not already exist; if it is created as part of the
6629
 
       upgrade process, it will be disabled initially. You may wish
6630
 
       to enable this user profile so that it can be used to start
6631
 
       the MySQL server later. It is best practice to use the one
6632
 
       previously created during the first installation.
6633
 
 
6634
 
     * MYSQLUSR('root user') --- any user account in the current
6635
 
       MySQL server with SUPER privileges.
6636
 
 
6637
 
     * PASSWORD('root user password') --- the password for the above
 
6659
     * USRPRF('MYSQL'): Sets the user profile that will own the files
 
6660
       that are installed. The profile will be created if it does not
 
6661
       already exist; if it is created as part of the upgrade
 
6662
       process, it will be disabled initially. You may wish to enable
 
6663
       this user profile so that it can be used to start the MySQL
 
6664
       server later. It is best practice to use the one previously
 
6665
       created during the first installation.
 
6666
 
 
6667
     * MYSQLUSR('root user'): Any user account in the current MySQL
 
6668
       server with SUPER privileges.
 
6669
 
 
6670
     * PASSWORD('root user password'): The password for the above
6638
6671
       account. This is necessary as the upgrade starts the MySQL
6639
6672
       server to upgrade the tables and the password is need to be
6640
6673
       able to shutdown the MySQL server.
6641
6674
 
6642
 
     * CURINST('path to previous install') --- the full path to the
 
6675
     * CURINST('path to previous install'): The full path to the
6643
6676
       installation that is being upgraded. For example an
6644
6677
       installation in /QOpenSys/usr/local/ will be
6645
6678
       /QOpenSys/usr/local/msyql-5.1.30-i5os-power64. Failure to
6850
6883
aCC: warning 901: unknown option: `-3': use +help for online
6851
6884
documentation
6852
6885
 
6853
 
   If you get the following error from configure, verify that you
6854
 
   don't have the path to the K&R compiler before the path to the
6855
 
   HP-UX C and C++ compiler:
 
6886
   If you get the following error from configure, verify that you do
 
6887
   not have the path to the K&R compiler before the path to the HP-UX
 
6888
   C and C++ compiler:
6856
6889
checking for cc option to accept ANSI C... no
6857
6890
configure: error: MySQL requires an ANSI C compiler (and a C++ compil
6858
6891
er).
6908
6941
 
6909
6942
   The -Wa,-many option is necessary for the compile to be
6910
6943
   successful. IBM is aware of this problem but is in no hurry to fix
6911
 
   it because of the workaround that is available. We don't know if
 
6944
   it because of the workaround that is available. We do not know if
6912
6945
   the -fno-exceptions is required with gcc 2.95, but because MySQL
6913
6946
   doesn't use exceptions and the option generates faster code, you
6914
6947
   should always use it with gcc.
6919
6952
   604 or 604e. We are not positive but suspect that power would
6920
6953
   likely be safe most of the time, even on a power2 machine.
6921
6954
 
6922
 
   If you don't know what your CPU is, execute a uname -m command. It
6923
 
   produces a string that looks like 000514676700, with a format of
6924
 
   xxyyyyyymmss where xx and ss are always 00, yyyyyy is a unique
 
6955
   If you do not know what your CPU is, execute a uname -m command.
 
6956
   It produces a string that looks like 000514676700, with a format
 
6957
   of xxyyyyyymmss where xx and ss are always 00, yyyyyy is a unique
6925
6958
   system ID and mm is the ID of the CPU Planar. A chart of these
6926
6959
   values can be found at
6927
6960
   http://www16.boulder.ibm.com/pseries/en_US/cmds/aixcmds5/uname.htm
7045
7078
 
7046
7079
2.13.1. Unix Post-Installation Procedures
7047
7080
 
7048
 
   After installing MySQL on Unix, you need to initialize the grant
 
7081
   After installing MySQL on Unix, you must initialize the grant
7049
7082
   tables, start the server, and make sure that the server works
7050
7083
   satisfactorily. You may also wish to arrange for the server to be
7051
7084
   started and stopped automatically when your system starts and
7065
7098
   Otherwise, you'll need to run mysql_install_db yourself.
7066
7099
 
7067
7100
   The following procedure describes how to initialize the grant
7068
 
   tables (if that has not previously been done) and then start the
 
7101
   tables (if that has not previously been done) and start the
7069
7102
   server. It also suggests some commands that you can use to test
7070
7103
   whether the server is accessible and working properly. For
7071
7104
   information about starting and stopping the server automatically,
7073
7106
 
7074
7107
   After you complete the procedure and have the server running, you
7075
7108
   should assign passwords to the accounts created by
7076
 
   mysql_install_db. Instructions for doing so are given in Section
7077
 
   2.13.2, "Securing the Initial MySQL Accounts."
 
7109
   mysql_install_db and perhaps secure access to test databases. For
 
7110
   instructions, see Section 2.13.2, "Securing the Initial MySQL
 
7111
   Accounts."
7078
7112
 
7079
7113
   In the examples shown here, the server runs under the user ID of
7080
7114
   the mysql login account. This assumes that such an account exists.
7086
7120
       installation, represented here by BASEDIR:
7087
7121
shell> cd BASEDIR
7088
7122
       BASEDIR is likely to be something like /usr/local/mysql or
7089
 
       /usr/local. The following steps assume that you are located in
7090
 
       this directory.
 
7123
       /usr/local. The following steps assume that you have changed
 
7124
       location to this directory.
7091
7125
 
7092
7126
    2. If necessary, run the mysql_install_db program to set up the
7093
7127
       initial MySQL grant tables containing the privileges that
7114
7148
         --datadir=/opt/mysql/mysql/data
7115
7149
       The mysql_install_db script creates the server's data
7116
7150
       directory. Under the data directory, it creates directories
7117
 
       for the mysql database that holds all database privileges and
7118
 
       the test database that you can use to test MySQL. The script
7119
 
       also creates privilege table entries for root and
7120
 
       anonymous-user accounts. The accounts have no passwords
7121
 
       initially. A description of their initial privileges is given
7122
 
       in Section 2.13.2, "Securing the Initial MySQL Accounts."
7123
 
       Briefly, these privileges allow the MySQL root user to do
7124
 
       anything, and allow anybody to create or use databases with a
7125
 
       name of test or starting with test_.
 
7151
       for the mysql database that holds the grant tables and the
 
7152
       test database that you can use to test MySQL. The script also
 
7153
       creates privilege table entries for root and anonymous-user
 
7154
       accounts. The accounts have no passwords initially. Section
 
7155
       2.13.2, "Securing the Initial MySQL Accounts," describes the
 
7156
       initial privileges. Briefly, these privileges allow the MySQL
 
7157
       root user to do anything, and allow anybody to create or use
 
7158
       databases with a name of test or starting with test_.
7126
7159
       It is important to make sure that the database directories and
7127
7160
       files are owned by the mysql login account so that the server
7128
7161
       has read and write access to them when you run it later. To
7134
7167
       including user, db, host, tables_priv, columns_priv, func, and
7135
7168
       others. See Section 5.4, "The MySQL Access Privilege System,"
7136
7169
       for a complete listing and description of these tables.
7137
 
       If you don't want to have the test database, you can remove it
7138
 
       with mysqladmin -u root drop test after starting the server.
 
7170
       If you do not want to have the test database, you can remove
 
7171
       it after starting the server, using the instructions in
 
7172
       Section 2.13.2, "Securing the Initial MySQL Accounts."
7139
7173
       If you have trouble with mysql_install_db at this point, see
7140
7174
       Section 2.13.1.1, "Problems Running mysql_install_db."
7141
7175
 
7150
7184
       Further instructions for running MySQL as an unprivileged user
7151
7185
       are given in Section 5.3.6, "How to Run MySQL as a Normal
7152
7186
       User."
7153
 
       If you neglected to create the grant tables before proceeding
7154
 
       to this step, the following message appears in the error log
7155
 
       file when you start the server:
 
7187
       If you neglected to create the grant tables by running
 
7188
       mysql_install_db before proceeding to this step, the following
 
7189
       message appears in the error log file when you start the
 
7190
       server:
7156
7191
mysqld: Can't find file: 'host.frm'
 
7192
       This error also occurs if you run mysql_install_db as root
 
7193
       without the --user option. Remove the data directory and run
 
7194
       mysql_install_db with the --user option as described
 
7195
       previously.
7157
7196
       If you have other problems starting the server, see Section
7158
7197
       2.13.1.3, "Starting and Troubleshooting the MySQL Server."
7159
7198
 
7166
7205
       on your platform and version of MySQL, but should be similar
7167
7206
       to that shown here:
7168
7207
shell> bin/mysqladmin version
7169
 
mysqladmin  Ver 14.12 Distrib 5.1.48, for pc-linux-gnu on i686
 
7208
mysqladmin  Ver 14.12 Distrib 5.1.49, for pc-linux-gnu on i686
7170
7209
...
7171
7210
 
7172
 
Server version          5.1.48
 
7211
Server version          5.1.49
7173
7212
Protocol version        10
7174
7213
Connection              Localhost via UNIX socket
7175
7214
UNIX socket             /var/lib/mysql/mysql.sock
7251
7290
       tests, execute these commands:
7252
7291
shell> cd sql-bench
7253
7292
shell> perl run-all-tests
7254
 
       If you don't have the sql-bench directory, you probably
 
7293
       If you do not have the sql-bench directory, you probably
7255
7294
       installed MySQL using RPM files other than the source RPM.
7256
7295
       (The source RPM includes the sql-bench benchmark directory.)
7257
7296
       In this case, you must first install the benchmark suite
7605
7644
   the default path settings are by invoking mysqld with the
7606
7645
   --verbose and --help options.
7607
7646
 
7608
 
   If the default locations don't match the MySQL installation layout
7609
 
   on your system, you can override them by specifying options to
7610
 
   mysqld or mysqld_safe on the command line or in an option file.
 
7647
   If the default locations do not match the MySQL installation
 
7648
   layout on your system, you can override them by specifying options
 
7649
   to mysqld or mysqld_safe on the command line or in an option file.
7611
7650
 
7612
7651
   To specify the location of the data directory explicitly, use the
7613
7652
   --datadir option. However, normally you can tell mysqld the
7694
7733
 
7695
7734
   If no other server is running, try to execute the command telnet
7696
7735
   your_host_name tcp_ip_port_number. (The default MySQL port number
7697
 
   is 3306.) Then press Enter a couple of times. If you don't get an
 
7736
   is 3306.) Then press Enter a couple of times. If you do not get an
7698
7737
   error message like telnet: Unable to connect to remote host:
7699
7738
   Connection refused, some other program is using the TCP/IP port
7700
7739
   that mysqld is trying to use. You'll need to track down what
7725
7764
   Part of the MySQL installation process is to set up the mysql
7726
7765
   database that contains the grant tables:
7727
7766
 
7728
 
     * Windows distributions contain preinitialized grant tables that
7729
 
       are installed automatically.
7730
 
 
7731
 
     * On Unix, the grant tables are populated by the
7732
 
       mysql_install_db program. Some installation methods run this
7733
 
       program for you. Others require that you execute it manually.
7734
 
       For details, see Section 2.13.1, "Unix Post-Installation
7735
 
       Procedures."
7736
 
 
7737
 
   The grant tables define the initial MySQL user accounts and their
7738
 
   access privileges. These accounts are set up as follows:
7739
 
 
7740
 
     * Accounts with the user name root are created. These are
7741
 
       superuser accounts that can do anything. The initial root
7742
 
       account passwords are empty, so anyone can connect to the
7743
 
       MySQL server as root --- without a password --- and be granted
7744
 
       all privileges.
7745
 
 
7746
 
          + On Windows, one root account is created; this account
7747
 
            allows connecting from the local host only. The Windows
7748
 
            installer will optionally create an account allowing for
7749
 
            connections from any host only if the user selects the
7750
 
            Enable root access from remote machines option during
7751
 
            installation.
7752
 
 
7753
 
          + On Unix, both root accounts are for connections from the
7754
 
            local host. Connections must be made from the local host
7755
 
            by specifying a host name of localhost for one of the
7756
 
            accounts, or the actual host name or IP number for the
7757
 
            other.
7758
 
 
7759
 
     * Two anonymous-user accounts are created, each with an empty
 
7767
     * Windows distributions contain preinitialized grant tables.
 
7768
 
 
7769
     * On Unix, the mysql_install_db program populates the grant
 
7770
       tables. Some installation methods run this program for you.
 
7771
       Others require that you execute it manually. For details, see
 
7772
       Section 2.13.1, "Unix Post-Installation Procedures."
 
7773
 
 
7774
   The mysql.user grant table defines the initial MySQL user accounts
 
7775
   and their access privileges:
 
7776
 
 
7777
     * Some accounts have the user name root. These are superuser
 
7778
       accounts that have all privileges and can do anything. The
 
7779
       initial root account passwords are empty, so anyone can
 
7780
       connect to the MySQL server as root without a password and be
 
7781
       granted all privileges.
 
7782
 
 
7783
          + On Windows, root accounts are created that allow
 
7784
            connections from the local host only. Connections can be
 
7785
            made by specifying a host name of localhost or 127.0.0.1.
 
7786
            If the user selects the Enable root access from remote
 
7787
            machines option during installation, the Windows
 
7788
            installer creates another root account that allows
 
7789
            connections from any host.
 
7790
 
 
7791
          + On Unix, each root account allows connections from the
 
7792
            local host. Connections can be made by specifying a host
 
7793
            name of localhost, 127.0.0.1, or the actual host name or
 
7794
            IP number.
 
7795
       An attempt to connect to the host 127.0.0.1 normally resolves
 
7796
       to the localhost account. However, this fails if the server is
 
7797
       run with the --skip-name-resolve option, so the 127.0.0.1
 
7798
       account is useful in that case.
 
7799
 
 
7800
     * Some accounts are for anonymous users. These have an empty
7760
7801
       user name. The anonymous accounts have no password, so anyone
7761
7802
       can use them to connect to the MySQL server.
7762
7803
 
7763
 
          + On Windows, one anonymous account is for connections from
7764
 
            the local host. It has no global privileges. (Before
7765
 
            MySQL 5.1.16, it has all global privileges, just like the
7766
 
            root accounts.) The other is for connections from any
7767
 
            host and has all privileges for the test database and for
7768
 
            other databases with names that start with test.
7769
 
 
7770
 
          + On Unix, both anonymous accounts are for connections from
7771
 
            the local host. Connections must be made from the local
7772
 
            host by specifying a host name of localhost for one of
7773
 
            the accounts, or the actual host name or IP number for
7774
 
            the other. These accounts have all privileges for the
7775
 
            test database and for other databases with names that
7776
 
            start with test_.
7777
 
 
7778
 
   As noted, none of the initial accounts have passwords. This means
7779
 
   that your MySQL installation is unprotected until you do something
7780
 
   about it:
 
7804
          + On Windows, there is one anonymous account that allows
 
7805
            connections from the local host. Connections can be made
 
7806
            by specifying a host name of localhost. The account has
 
7807
            no global privileges. (Before MySQL 5.1.16, it has all
 
7808
            global privileges, just like the root accounts.)
 
7809
 
 
7810
          + On Unix, each anonymous account allows connections from
 
7811
            the local host. Connections can be made by specifying a
 
7812
            host name of localhost for one of the accounts, or the
 
7813
            actual host name or IP number for the other.
 
7814
 
 
7815
   To display which accounts exist in the mysql.user table and check
 
7816
   whether their passwords are empty, use the following statement:
 
7817
mysql> SELECT User, Host, Password FROM mysql.user;
 
7818
+------+--------------------+----------+
 
7819
| User | Host               | Password |
 
7820
+------+--------------------+----------+
 
7821
| root | localhost          |          |
 
7822
| root | myhost.example.com |          |
 
7823
| root | 127.0.0.1          |          |
 
7824
|      | localhost          |          |
 
7825
|      | myhost.example.com |          |
 
7826
+------+--------------------+----------+
 
7827
 
 
7828
   This output indicates that there are several root and
 
7829
   anonymous-user accounts, none of which have passwords. The output
 
7830
   might differ on your system, but the presence of accounts with
 
7831
   empty passwords means that your MySQL installation is unprotected
 
7832
   until you do something about it:
 
7833
 
 
7834
     * You should assign a password to each MySQL root account.
7781
7835
 
7782
7836
     * If you want to prevent clients from connecting as anonymous
7783
7837
       users without a password, you should either assign a password
7784
7838
       to each anonymous account or else remove the accounts.
7785
7839
 
7786
 
     * You should assign a password to each MySQL root account.
 
7840
   In addition, the mysql.db table contains rows that allow all
 
7841
   accounts access to the test database and other databases with
 
7842
   names that start with test_. This is true even for accounts that
 
7843
   otherwise have no special privileges such as the default anonymous
 
7844
   accounts. This is convenient for testing, but administrators may
 
7845
   want database access restricted only to accounts that have
 
7846
   permissions granted explicitly for that purpose, particularly on
 
7847
   production servers. Such administrators should remove these
 
7848
   mysql.db table rows.
7787
7849
 
7788
7850
   The following instructions describe how to set up passwords for
7789
 
   the initial MySQL accounts, first for the anonymous accounts and
7790
 
   then for the root accounts. Replace "newpwd" in the examples with
7791
 
   the actual password that you want to use. The instructions also
7792
 
   cover how to remove the anonymous accounts, should you prefer not
7793
 
   to allow anonymous access at all.
7794
 
 
7795
 
   You might want to defer setting the passwords until later, so that
7796
 
   you don't need to specify them while you perform additional setup
 
7851
   the initial MySQL accounts, first for for the root accounts, then
 
7852
   for the anonymous accounts. The instructions also cover how to
 
7853
   remove the anonymous accounts, should you prefer not to allow
 
7854
   anonymous access at all, and describe how to remove permissive
 
7855
   access to test databases. Replace newpwd in the examples with the
 
7856
   password that you want to use. Replace host_name with the name of
 
7857
   the server host. You can determine this name from the output of
 
7858
   the preceding SELECT statement. For the output shown, host_name is
 
7859
   myhost.example.com.
 
7860
 
 
7861
Note
 
7862
 
 
7863
   If you forget your root password after setting it, see Section
 
7864
   B.5.4.1, "How to Reset the Root Password."
 
7865
 
 
7866
   You might want to defer setting the passwords until later, to
 
7867
   avoid the need to specify them while you perform additional setup
7797
7868
   or testing. However, be sure to set them before using your
7798
7869
   installation for production purposes.
7799
7870
 
7800
 
   Anonymous Account Password Assignment
7801
 
 
7802
 
   To assign passwords to the anonymous accounts, connect to the
7803
 
   server as root and then use either SET PASSWORD or UPDATE. In
7804
 
   either case, be sure to encrypt the password using the PASSWORD()
7805
 
   function.
7806
 
 
7807
 
   To use SET PASSWORD on Windows, do this:
7808
 
shell> mysql -u root
7809
 
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
7810
 
mysql> SET PASSWORD FOR ''@'%' = PASSWORD('newpwd');
7811
 
 
7812
 
   To use SET PASSWORD on Unix, do this:
7813
 
shell> mysql -u root
7814
 
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
7815
 
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');
7816
 
 
7817
 
   In the second SET PASSWORD statement, replace host_name with the
7818
 
   name of the server host. This is the name that is specified in the
7819
 
   Host column of the non-localhost record for root in the user
7820
 
   table. If you don't know what host name this is, issue the
7821
 
   following statement before using SET PASSWORD:
7822
 
mysql> SELECT Host, User FROM mysql.user;
7823
 
 
7824
 
   Look for the record that has root in the User column and something
7825
 
   other than localhost in the Host column. Then use that Host value
7826
 
   in the second SET PASSWORD statement.
7827
 
 
7828
 
   Anonymous Account Removal
7829
 
 
7830
 
   If you prefer to remove the anonymous accounts instead, do so as
7831
 
   follows:
7832
 
shell> mysql -u root
7833
 
mysql> DROP USER '';
7834
 
 
7835
 
   The DROP statement applies both to Windows and to Unix. On
7836
 
   Windows, if you want to remove only the anonymous account that has
7837
 
   the same privileges as root, do this instead:
7838
 
shell> mysql -u root
7839
 
mysql> DROP USER ''@'localhost';
7840
 
 
7841
 
   That account allows anonymous access but has full privileges, so
7842
 
   removing it improves security.
7843
 
 
7844
 
   root Account Password Assignment
7845
 
 
7846
 
   You can assign passwords to the root accounts in several ways. The
7847
 
   following discussion demonstrates three methods:
 
7871
   To set up additional accounts, see Section 5.5.2, "Adding User
 
7872
   Accounts."
 
7873
 
 
7874
Assigning root Account Passwords
 
7875
 
 
7876
   The root account passwords can be set several ways. The following
 
7877
   discussion demonstrates three methods:
7848
7878
 
7849
7879
     * Use the SET PASSWORD statement
7850
7880
 
 
7881
     * Use the UPDATE statement
 
7882
 
7851
7883
     * Use the mysqladmin command-line client program
7852
7884
 
7853
 
     * Use the UPDATE statement
7854
 
 
7855
7885
   To assign passwords using SET PASSWORD, connect to the server as
7856
 
   root and issue SET PASSWORD statements. Be sure to encrypt the
7857
 
   password using the PASSWORD() function.
 
7886
   root and issue a SET PASSWORD statement for each root account
 
7887
   listed in the mysql.user table. Be sure to encrypt the password
 
7888
   using the PASSWORD() function.
7858
7889
 
7859
7890
   For Windows, do this:
7860
7891
shell> mysql -u root
7861
7892
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
 
7893
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
7862
7894
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('newpwd');
7863
7895
 
 
7896
   The last statement is unnecessary if the mysql.user table has no
 
7897
   root account with a host value of %.
 
7898
 
7864
7899
   For Unix, do this:
7865
7900
shell> mysql -u root
7866
7901
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
 
7902
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
7867
7903
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
7868
7904
 
7869
 
   In the second SET PASSWORD statement, replace host_name with the
7870
 
   name of the server host. This is the same host name that you used
7871
 
   when you assigned the anonymous account passwords.
 
7905
   You can also use a single statement that assigns a password to all
 
7906
   root accounts by using UPDATE to modify the mysql.user table
 
7907
   directly. This method works on any platform:
 
7908
shell> mysql -u root
 
7909
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
 
7910
    ->     WHERE User = 'root';
 
7911
mysql> FLUSH PRIVILEGES;
7872
7912
 
7873
 
   If the user table contains an account with User and Host values of
7874
 
   'root' and '127.0.0.1', use an additional SET PASSWORD statement
7875
 
   to set that account's password:
7876
 
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
 
7913
   The FLUSH statement causes the server to reread the grant tables.
 
7914
   Without it, the password change remains unnoticed by the server
 
7915
   until you restart it.
7877
7916
 
7878
7917
   To assign passwords to the root accounts using mysqladmin, execute
7879
7918
   the following commands:
7880
7919
shell> mysqladmin -u root password "newpwd"
7881
7920
shell> mysqladmin -u root -h host_name password "newpwd"
7882
7921
 
7883
 
   These commands apply both to Windows and to Unix. In the second
7884
 
   command, replace host_name with the name of the server host. The
7885
 
   double quotes around the password are not always necessary, but
 
7922
   Those commands apply both to Windows and to Unix. The double
 
7923
   quotation marks around the password are not always necessary, but
7886
7924
   you should use them if the password contains spaces or other
7887
7925
   characters that are special to your command interpreter.
7888
7926
 
7889
7927
   The mysqladmin method of setting the root account passwords does
7890
 
   not set the password for the 'root'@'127.0.0.1' account. To do so,
7891
 
   use SET PASSWORD as shown earlier.
7892
 
 
7893
 
   You can also use UPDATE to modify the user table directly. The
7894
 
   following UPDATE statement assigns a password to all root
7895
 
   accounts:
7896
 
shell> mysql -u root
7897
 
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
7898
 
    ->     WHERE User = 'root';
7899
 
mysql> FLUSH PRIVILEGES;
7900
 
 
7901
 
   The UPDATE statement applies both to Windows and to Unix.
7902
 
 
7903
 
   After the passwords have been set, you must supply the appropriate
7904
 
   password whenever you connect to the server. For example, if you
7905
 
   want to use mysqladmin to shut down the server, you can do so
7906
 
   using this command:
 
7928
   not work for the 'root'@'127.0.0.1' account. Use the SET PASSWORD
 
7929
   method shown earlier.
 
7930
 
 
7931
   After the root passwords have been set, you must supply the
 
7932
   appropriate password whenever you connect as root to the server.
 
7933
   For example, to shut down the server with mysqladmin, use this
 
7934
   command:
7907
7935
shell> mysqladmin -u root -p shutdown
7908
7936
Enter password: (enter root password here)
7909
7937
 
7910
 
Note
7911
 
 
7912
 
   If you forget your root password after setting it up, Section
7913
 
   B.5.4.1, "How to Reset the Root Password," covers the procedure
7914
 
   for resetting it.
7915
 
 
7916
 
   To set up additional accounts, you can use the GRANT statement.
7917
 
   For instructions, see Section 5.5.2, "Adding User Accounts."
 
7938
Assigning Anonymous Account Passwords
 
7939
 
 
7940
   The mysql commands in the following instructions include a -p
 
7941
   option based on the assumption that you have set the root account
 
7942
   passwords using the preceding instructions and must specify that
 
7943
   password when connecting to the server.
 
7944
 
 
7945
   To assign passwords to the anonymous accounts, connect to the
 
7946
   server as root, then use either SET PASSWORD or UPDATE. Be sure to
 
7947
   encrypt the password using the PASSWORD() function.
 
7948
 
 
7949
   To use SET PASSWORD on Windows, do this:
 
7950
shell> mysql -u root -p
 
7951
Enter password: (enter root password here)
 
7952
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
 
7953
 
 
7954
   To use SET PASSWORD on Unix, do this:
 
7955
shell> mysql -u root -p
 
7956
Enter password: (enter root password here)
 
7957
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('newpwd');
 
7958
mysql> SET PASSWORD FOR ''@'host_name' = PASSWORD('newpwd');
 
7959
 
 
7960
   To set the anonymous-user account passwords with a single UPDATE
 
7961
   statement, do this (on any platform):
 
7962
shell> mysql -u root -p
 
7963
Enter password: (enter root password here)
 
7964
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
 
7965
    ->     WHERE User = '';
 
7966
mysql> FLUSH PRIVILEGES;
 
7967
 
 
7968
   The FLUSH statement causes the server to reread the grant tables.
 
7969
   Without it, the password change remains unnoticed by the server
 
7970
   until you restart it.
 
7971
 
 
7972
Removing Anonymous Accounts
 
7973
 
 
7974
   If you prefer to remove any anonymous accounts rather than
 
7975
   assigning them passwords, do so as follows on Windows:
 
7976
shell> mysql -u root -p
 
7977
Enter password: (enter root password here)
 
7978
mysql> DROP USER ''@'localhost';
 
7979
 
 
7980
   On Unix, remove the anonymous accounts like this:
 
7981
shell> mysql -u root -p
 
7982
Enter password: (enter root password here)
 
7983
mysql> DROP USER ''@'localhost';
 
7984
mysql> DROP USER ''@'host_name';
 
7985
 
 
7986
Securing Test Databases
 
7987
 
 
7988
   By default, the mysql.db table contains rows that allow access by
 
7989
   any user to the test database and other databases with names that
 
7990
   start with test_. (These rows have an empty User column value,
 
7991
   which for access-checking purposes matches any user name.) This
 
7992
   means that such databases can be used even by accounts that
 
7993
   otherwise possess no privileges. If you want to remove any-user
 
7994
   access to test databases, do so as follows:
 
7995
shell> mysql -u root -p
 
7996
Enter password: (enter root password here)
 
7997
mysql> DELETE FROM mysql.db WHERE Db LIKE 'test%';
 
7998
mysql> FLUSH PRIVILEGES;
 
7999
 
 
8000
   The FLUSH statement causes the server to reread the grant tables.
 
8001
   Without it, the privilege change remains unnoticed by the server
 
8002
   until you restart it.
 
8003
 
 
8004
   With the preceding change, only users who have global database
 
8005
   privileges or privileges granted explicitly for the test database
 
8006
   can use it. However, if you do not want the database to exist at
 
8007
   all, drop it:
 
8008
mysql> DROP DATABASE test;
7918
8009
 
7919
8010
2.14. Environment Variables
7920
8011