Lamp Architecture & Installation MySQL

Source: Internet
Author: User

11.1 Lamp Architecture Introduction

Lamp refers to the Linux (operating system), Apache (httpd server), MySQL (Database software) and PHP (sometimes referred to as perl or Python) abbreviation, generally used to establish a Web server (three characters can be separated from a machine, But Apache and PHP are installed together).

Apache, PHP, MySQL working mode

Description: The picture, JS, CSS and other files on the server belong to static files, and the database files are dynamic files.

11.2 mysql_mariadb Introduction

MySQL is an associated database management system that keeps data in separate tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility.

MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance. MARIADB until version 5.5, all in accordance with the MySQL version. Starting from November 12, 2012, version 10.0.0 is no longer in accordance with the MySQL version number. Version 10.0.x is based on version 5.5, plus features ported from version MySQL5.6 and new features developed by yourself.

MySQL version:
Community Community Edition, Enterprise Business Edition, GA (generally available) General edition, used in production environments; DMR (development milestone release) development milestone version ; RC (Release Candidate) Release candidate version; Beta open test release; Alpha internal beta version.

11.3-11.5 MySQL Install uname command

The uname command is used to print information about the current system (kernel version number, hardware architecture, host name, operating system type, and so on).

syntax : uname [Options]
Options:
-a:=all, Show all information
-m:=machine, display computer type
-N: Host name displayed on the network
-R: Displays the operating system's release number
-S: Displays the operating system name
-V: Displays the operating system version
-P: Show processor type or "Unknown"
-I: Output hardware platform
-O: Output operating system name

MySQL Common installation package

RPM package, source package, binary compiler-free package.

mysql-5.6-64-bit binary free-build package Image: Http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

Install MySQL

Preparatory work

    • Switch to/usr/local/src/directory

      [[email protected] ~]# cd /usr/local/src/
    • Download MySQL binary free compiler package

      [[email protected] ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
    • Unpack the Package

      [[email protected] ~]# tar zxvf /usr/local/src/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
      Initialization
    • To move the installation files to the/usr/local/directory

      [Email protected] ~]# MV Mysql-5.6.35-linux-glibc2.5-x86_64/usr/local/mysql

    • Switch to the MySQL directory

      [Email protected] mysql]# cd/usr/local/mysql/

    • Create a MySQL user

      [[email protected] mysql]# useradd MySQL

    • Create a database directory

      [Email protected] mysql]# mkdir/data/

    • Initialization

      [Email protected] mysql]#/scripts/mysql_install_db--user=mysql--datadir=/data/mysql

Troubleshoot errors
    • Error tip 1:

      [Email protected] mysql]#/scripts/mysql_install_db--user=mysql--datadir=/data/mysql
      FATAL Error:please Install the following Perl modules before executing./SCRIPTS/MYSQL_INSTALL_DB:
      Data::D umper

      Workaround:
      根据提示搜索相应的安装包并进行安装:[[email protected] mysql]# yum install -y perl-Data-Dumper
    • Error Tip 2:

      [Email protected] mysql]#/scripts/mysql_install_db--user=mysql-Datadir=/data/mysql
      Installing MySQL system Tables..../bin/mysqld:error while loading shared libraries:libaio.so.1:cannot open shared objec T file:no such file or directory

Workaround:
    根据提示信息安装有关的库文件:    [[email protected] mysql]#  yum -y install libaio* libaio-dev*
Configure MySQL

Check that the "./scripts" command is executed correctly after you complete the above operation:

 [[email protected] mysql]# echo $?  0
  • Copy config file to/etc/my.cnf

    [email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf

  • Edit the system configuration file for MySQL/etc/my.cnf
    Change the contents of the template to the following format:
    [Email protected] mysql]# VIM/ETC/MY.CNF
    [Mysqld]
    Datadir=/data/mysql
    Socket=/tmp/mysql.sock
    #Disabling Symbolic-links is recommended to prevent assorted security risks
    Symbolic-links=0
    #Settings the user and group was ignored when SYSTEMD is used.
    #If need to run mysqld under a different user or group,
    #customize your systemd unit file for mariadb according
    #instructions in Http://fedoraproject.org/wiki/Systemd

    [Mysqld_safe]
    #log-error=/var/log/mariadb/mariadb.log
    #pid-file=/var/run/mariadb/mariadb.pid

      #        # include all files from the config directory  #  #!includedir /etc/my.cnf.d
  • modifying startup scripts

    Add the startup script to the system configuration file/etc/init.d/:
    [email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld

    To modify a configuration file:
    [Email protected] mysql]# Vim/etc/init.d/mysqld
    ......
    Basedir=/usr/local/mysql
    Datadir=/data/mysql
    ......

    Change profile permissions (default is 755):
    [Email protected] mysql]# chmod 755/etc/init.d/mysqld
    This step can be omitted!

  • Start the MySQL service
    Add the MySQL service to the boot-up service:
    [Email protected] mysql]# chkconfig--add mysqld
    [Email protected] mysql]# chkconfig--list
    Mysqld 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off
    Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
    Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

    Method 2:
    [[Email protected] mysql]# service mysqld start
    Starting mysql.logging to '/data/mysql/centos-01.err '.
    .. success!

  • To start the MySQL service abnormally:
    Scenario: The MySQL startup script cannot be added to/etc/init.d/or does not have a startup script and can be started using the following method:

    [Email protected] mysql]#/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my.cnf--user=mysql--datadir=/data /mysql &

    Execute the command in the background kill command &killall command

Both the KILL command and the Killall command are used to kill the process in the system, the difference being:

Kill is used to kill a single process, killall is used to kill the process tree
Using the KILL command immediately ends a running process, and if the process is reading and writing the disk, the data is lost due to the end of the process, and the Killall command waits for the data to be read and written before ending the related process, which is relatively safe to use.

Lamp Architecture & Installation MySQL

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.