Linux manual installation MySQL

Source: Internet
Author: User
Tags mysql client unpack

The following is an excerpt from the official MySQL documentation about manually installing the MySQL binary distribution:

One: Installation

The basic commands that must be performed to install and use the MySQL binary distribution are:

shell> Groupadd MySQL

shell> useradd-g MySQL MySQL

Shell> cd/usr/local

Shell> Gunzip </path/to/mysql-version-os. tar.gz | Tar xvf-

shell> ln-s Full-path-to-mysql-version-os MySQL

shell> CD MySQL

Shell> scripts/mysql_install_db--user=mysql

Shell> chown-r Root.

shell> chown-r MySQL Data

Shell> chgrp-r MySQL.

Shell> bin/mysqld_safe--user=mysql &


Note: This procedure does not set the password for the MySQL account. After you complete the following procedure, continue to think of section 2.9, "Setup and testing after installation."

The following is a more detailed description of installing the binary distribution:

1. Add a login user and group to mysqld:

2.shell> groupadd MySQL

3.shell> useradd-g MySQL mysql

These commands will increase the MySQL group and the MySQL user. The syntax for Useradd and Groupadd may be slightly different in different versions of UNIX. It can also be called AddUser and AddGroup. You might name these users and groups outside of MySQL. If so, replace it with the appropriate name in the following steps.

4. Select a directory where you want to unpack the distribution package and enter it. In the following example, we will distribute the unpacked under "/usr/local" (so the following instructions assume you have permission to create files and directories in "/usr/local", and if that directory is protected, you need to install it as root).

5. Shell> cd/usr/local

6. From section 2.1.3, "How to get MySQL" One of the sites listed in get a distribution file. For a given version, the binary distributions for all platforms are built from the same MySQL source distribution.

7. Unpack the distribution and create the installation directory. Then generate a symbolic link to the directory:

8.shell> Gunzip </path/to/mysql-version-os. tar.gz | tar xvf-

9.shell> ln-s full-path-to-mysql-version-os MySQL

The tar command creates the Mysql-version-os directory. The ln command generates a symbolic link to the directory. This makes it easier for you to designate the installation directory as/usr/local/mysql. With GNU tar, Gunzip is no longer required. You can use the following command to replace the first line to unpack and extract the distribution:

shell> tar zxvf/path/to/mysql-version-os.tar.gz

10. Enter the installation directory:

shell> CD MySQL

You will find several files and subdirectories in the MySQL directory, the "bin" and "scripts" subdirectories that are most important for installation purposes. Bin This directory contains client programs and servers, you should add the full path of this directory to the PATH environment variable, so that the shell can correctly find the MySQL program. See Appendix F: Environment variables. Scripts this directory contains the mysql_install_db script, which is used to initialize the authorization table for the MySQL database, which stores the server access permission.

12. If MySQL is not installed, you must create a MySQL authorization form

13.shell> scripts/mysql_install_db--user=mysql

If you run the command with root, you should use the--user option. The value of the option should be the same as the login account you created in the first step for the running server. If you use this user login to run the command, you can omit the--user option. After you create or upgrade the authorization table, you need to manually restart the server.

14. Change the ownership of the program binaries to root and change the ownership of the data directory to the user running mysqld. If you are in the installation directory (/USR/LOCAL/MYSQL), the command should be:

15.shell> chown-r root.

16.shell> chown-r MySQL data

17.shell> chgrp-r MySQL.

The first command changes all properties of the file to the root user. The second command changes all the properties of the data directory to the MySQL user. The third command changes the group properties to a MySQL group.

18. If you prefer to start MySQL automatically when booting the machine, you can copy the Support-files/mysql.server file to the place where the system has the boot file. More information can be found in the Support-files/mysql.server script and in the 2.9.2.2 section, "Autostart and stop MySQL".

19. If the DBI and Dbd::mysql Perl modules are installed, you can use the Bin/mysql_setpermission script to add new accounts. For instructions, see section 2.13, "Perl Installation Considerations".


20. If you want to use mysqlaccess and have a MySQL distribution in a non-standard location, you must change the location where Mysqlaccess expects to find the MySQL client. Edit the "bin/mysqlaccess" script, on line 18th, looking for a line similar to the following:

MYSQL = '/usr/local/bin/mysql '; # path to MySQL executable

Change the path to reflect where MySQL is actually stored on your system. If you do not, you will encounter a broken pipe error when running mysqlaccess. After all things are unpacked and installed, you should initialize and test your distribution. You can start the MySQL server with the following command:

shell> bin/mysqld_safe--user=mysql &

For more information about Mysqld_safe See section 5.1, 3, "Mysqld_safe:mysql Server Startup Script".

Note: The account in the MySQL authorization form starts without a password. After starting the server, you should use the instructions in section 2.9, "Setup and test after installation" to set the password.

Two: Set the Power on automatically run

For a manually installed binary distribution version, we can find a script named Mysql.server in the Support-files directory under the MySQL installation directory. We need to copy this script to the/ETC/INIT.D directory, rename it to MySQL, and set the file to execute.


shell> CP Mysql.server/etc/init.d/mysql


shell> chmod +x/etc/init.d/mysql


The next work may vary depending on the Linux version. For some systems, we can use Chkconfig--add MySQL to complete the startup program registration. For Ubuntu, we should use Ubuntu's UPDATE-RC.D solution (Chkconfig for Linux, the newly released version of Ubuntu does not include this command)


Shell>sudo update-rc.d MySQL Defaults


With the above settings, MySQL will start automatically on Ubuntu.

Linux manual installation MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.