Installation and startup of MySQL under Linux (reprint)

Source: Internet
Author: User

Original link: http://www.linuxidc.com/Linux/2016-07/133234.htm, mysql comparison of various installation methods

Under the Linux system, there are 3 main ways to install MySQL: RPM installation, binary installation, source installation. The advantages and disadvantages of the three mounting methods are shown in the following table:

RPM Installation Binary installation SOURCE Installation
Advantages Easy to install, suitable for beginners Simple installation, can be installed to any path Can be customized according to the needs of the compilation, flexible, Best performance
Disadvantages Need to download the server and client separately, the installation path is not flexible, the default path cannot be modified has been compiled, performance is not as good as the source installation, can not flexibly customize the compilation parameters Complex installation process, long compilation time
File layout
  • /usr/bin (client programs and scripts)
  • /usr/sbin (mysqld server)
  • /var/lib/mysql (log files and databases)
  • /usr/include/mysql (header file)
  • /usr/lib/mysql (library file)
  • /usr/share/mysql (Error message and character set file)
  • Bin (mysqld server and client program)
  • Data (log files and databases)
  • Include (header file)
  • LIB (library file)
  • Scripts (mysql_install_db script)
  • Share/mysql (Error message)
Second, RPM installation process description

To access Http://dev.mysql.com/downloads/mysql/5.6.html#downloads, select the RPM installation package that downloads the corresponding version and the number of digits, as shown in:

Run the following command to complete the installation.

1 rpm -ivh MySQL-devel-5.6.31-1.el6.x86_64.rpm
Three or two binary installation process description

(1), add MySQL user and user group

12 groupadd mysqluseradd -g mysql mysql

(2), unzip the binary installation package, put in the specified directory.

(3), initialize the database, create the base table of the database.

1 ./mysql_install_db --user=mysql

(4), according to the actual needs, set the appropriate directory permissions.

Iv. description of the source code installation process

(1), download, unzip the source package.

(2), install the necessary software packages.

1234 1.cmake2.ncurses-develyum install cmake ncurses-devel -y

(3), creating users and groups

12 groupadd mysqluseradd mysql -s /sbin/nologin -M -g mysql

(4), compiling parameters and installation

12345678910111213141516171819 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.28 \-DMYSQL_DATADIR=/usr/local/mysql-5.6.28/data \-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.6.28/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=uft8_general_ci \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0make && make install

(5), Generate link Directory

1 ln -s /usr/local/mysql-5.6.28 /usr/local/mysql

(6), ADD environment variable

12 echo ‘export PATH=/usr/local/mysql/bin:$PATH‘>> /etc/profilesource /etc/profile

(7), modify directory Permissions

1 chown -R mysql.mysql /usr/local/mysql-5.6.28

(8), initialize the database, generate the base table

12 /usr/local/mysql/scripts./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

(9), configure MySQL boot file

123 cd /usr/local/mysql/support-filescp mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld

V. Startup and shutdown of MySQL

(1), for the use of RPM installation, you can use system services to start and close MySQL.

12 service mysqld start  #启动mysqlservice mysqld stop  #关闭mysql

(2), for binary and source installation, you can find the MySQL boot file from the installation directory (refer to the 9th step of compiling the installation process, of course, you can also write one yourself), and then copy to/etc/init.d/mysqld, used to start and close MySQL, You can also use the Chkconfig command to join the system service.

123 /etc/init.d/mysqld start    #启动mysql/etc/init.d/mysqld stop      #关闭mysql/etc/init.d/mysqld restart  #重启mysql

(3), MySQL startup fundamentals

/etc/init.d/mysqld is a shell script that invokes the Mysqld_safe script during the startup process and finally calls the Mysqld service to start MySQL. The Mysqld_safe program is called in the/etc/init.d/mysqld script as shown below.

1 $bindir/mysql_safe --datadir="$datadir"--pid-file="$mysqld_pid_file_path" $other_args >/dev/null2>&1 &

(4), in addition we can also use the mysqladmin command to turn off MySQL

1 mysqladmin -uroot -ppassword shutdown #只有具有mysql的root用户才能执行关闭操作。

(5), non-test environment does not recommend the MySQL shutdown method

123 killall mysqldpkill mysqldkillall -9 mysqld

Installation and startup of MySQL under Linux (reprint)

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.