MySQL Database Service Establishment

Source: Internet
Author: User
MySQL is an open-source relational database server software. It is currently developed and maintained by Oracle. To ensure the integrity and customization of the MySQL database, the source code is used in this experiment.

MySQL is an open-source relational database server software. It is currently developed and maintained by Oracle. To ensure the integrity and customization of the MySQL database, the source code is used in this experiment.

MySQL service basics:

  • MySQL

  • MySQL features multiple threads and users. It is based on the C/S (Client/Server) architecture. It is easy to use, fast to query, and secure and reliable.

  • Recommended reading:

    Create a virtual machine for the vsftpd server using the MySQL database in Ubuntu

    CentOS 6.3 64-bit MySQL5.1.54 installation and configuration of source code

    MySQL compilation and installation:

    To ensure the integrity and customization of the MySQL database, this experiment uses the source code compilation method to install the MySQL database system. Software: mysql-5.1.55.tar.gz.

    1. preparations:

    To avoid port conflicts and program conflicts, we recommend that you first query the installation status of MySQL software:

    [Root @ ns ~] # Rpm-q mysql-server mysql

    2. source code compilation and installation:

    Create a running user (to enhance the permission control of the Database Service, we recommend that you use a special running user, such as: mysql, which does not need to be directly logged on to the system ):

    [Root @ ns ~] # Useradd-M-s/sbin/nologin mysql

    Decompress the package (decompress the downloaded mysql source code package and release it to the/usr/src/directory ):

    Configure (set the default character set to utf8 and add support for other characters such as gbk and gb2312 ):

    Necessary work (install the corresponding ncurses dependency package ):

    [Root @ ns ~] # Yum-y install ncurses *

    [Root @ ns mysql-5.1.55] #. /configure -- prefix =/usr/local/mysql -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = gbk, gb2312

    Command description:

  • -- Prefix: Specifies the directory to which the mysql database program is installed;

  • -- With-charset: Specifies the default character set encoding, which corresponds to the verification rules. For example: utf8;

  • -- With-collation: Specifies the default character set verification rules, utf8_general_ci is a general rule for the UTF-8 Character Set;

  • Compile and install:

    3. Other adjustments after installation:

    Create a configuration file (under the support-files folder in the mysql source directory, provides sample configuration files suitable for different load databases; if you are not sure about the size of the database system application, generally select the my-medium.cnf file):

    [Root @ ns mysql-5.1.55] # cp support-files/my-medium.cnf/etc/my. cnf

    Initialize the database (in order to be able to use the MySQL database system normally, the initialization task should be executed as the running user mysql, so as to establish the user authorization library, table, and test database. Initialization Script mysql_install_db is located in the binfile of the installation directory; at the same time, you have to adjust the folder to store the database content): [root @ ns mysql-5.1.55] # cd/usr/local/mysql/bin/

    [Root @ ns bin] #./mysql_install_db -- user = mysql

    [Root @ ns bin] # chown-R root: mysql/usr/local/mysql/

    [Root @ ns bin] # chown-R mysql/usr/local/mysql/var/

    Optimize the execution path and library path (add a symbolic link to the program to facilitate use ):

    [Root @ ns bin] # ln-s/usr/local/mysql/bin/*/usr/local/bin/

    [Root @ ns bin] # ln-s/usr/local/mysql/lib/mysql/*/usr/lib/

    [Root @ ns bin] # ln-s/usr/local/mysql/include/mysql/*/usr/include/

    4. Add system services:

    Add the mysqld System Service and manage it through chkconfig to directly use the service script provided in the source code package.

    Locate the mysql. server script file in the support-files folder, copy it to the/etc/init. d/directory, change it to mysqld, and set the execution permission.

    [Root @ ns bin] # cd/usr/src/mysql-5.1.55/

    [Root @ ns mysql-5.1.55] # cp support-files/mysql. server/etc/init. d/mysqld

    [Root @ ns mysql-5.1.55] # chmod a + x/etc/init. d/mysqld

    [Root @ ns mysql-5.1.55] # chkconfig -- add mysqld

    Use the service tool or directly execute the/etc/init. d/mysqld script to control the MySQL database service.

    [Root @ ns mysql-5.1.55] #/etc/init. d/mysqld start

    [Root @ ns mysql-5.1.55] #/etc/init. d/mysqld status

    [Root @ ns mysql-5.1.55] # netstat-anpt | grep mysqld

    By default, the MySQL server provides services through TCP port 3306.

    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.