Lamp Deployment--two. Compiling and installing MySQL

Source: Internet
Author: User

Lamp Component Introduction
    • Lamp refers to Linux, Apache,mysql and PHP abbreviation, many production environments are used lamp architecture, in the Network application and development environment, lamp combination is very good, their combination provides a powerful function.
    • Linux, as the underlying operating system, provides a flexible and secure application platform, which guarantees the stable operation of other components.
    • Apache, as a Web server, provides a powerful, stable and supportive web platform;
    • MySQL is also a good database software;
    • PHP is a development scripting language, can be embedded in HTML, for Web development;
Preparatory work

Operating system: RHEL 6.5

Related software package: Baidu Network disk Password: Bty7

The native system image is mounted to/mnt/cdrom/(used when installing a dependent package)

Second, MySQL installation
    1. Unzip MySQL file to/opt/

      tar zxvf mysql-5.5.24.tar.gz -C /opt/
    2. Installation environment package, GCC, gcc-c++, make, CMake
yum install gcc gcc-c++ make cmake -y
    1. Installing Ncurses-devel, bison, libaio-devel packages
#进入系统镜像Packages目录下,安装三个依赖包cd /mnt/cdrom/Packagesrpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpmrpm -ivh bison-2.4.1-5.el6.x86_64.rpmrpm -ivh libaio-devel-0.3.107-10.el6.x86_64.rpm
    1. Add MySQL user and join to MySQL Group
groupadd mysqluseradd  -g mysql  mysql -s /sbin/nologinmkdir -p /usr/local/mysql

5. Go to the MySQL installation file directory

cd /opt/mysql-5.5.24

5.1 Configuration

Cmake-dcmake_install_prefix=/usr/local/mysql
-dmysql_unix_addr=/home/mysql/mysql.
-ddefault_charset=utf8
-ddefault_collation=utf8_general_ci
-dwith_extra_charsets=all
-dwith_myisam_storage_engine=1
-dwith_innobase_storage_engine=1
-dwith_memory_storage_engine=1
-dwith_readline=1
-denabled_local_infile=1
-dmysql_datadir=/home/mysql
-dmysql_user=mysql
-dmysql_tcp_port=3306

5.2 Compiling and installing the software

make && make install  

If error, empty cache file-if normal can be ignored
Find-name CMakeCache.txt
Rm-f./cmakecache.txt

    1. Modify MySQL file's owner, genus Group
chown -R mysql.mysql /usr/local/mysql         
    1. Adding Global environment variables

#在最后一行加入
Path= $PATH:/usr/local/mysql/bin/
: wq! #保存退出

    1. Reload Profile Contents
    1. Go to MySQL directory, copy my.cnf (config file), mysqld (startup script)
cd /opt/mysql-5.5.24/cp support-files/my-medium.cnf /etc/my.cnfcp support-files/mysql.server /etc/init.d/mysqld
    1. Modify permissions for mysqld startup scripts
chmod 755 /etc/init.d/mysqld#将mysqld服务添加进系统服务中,并设置init3、init5中开机自启动chkconfig --add /etc/init.d/mysqld                 chkconfig --level 35 mysqld on
    1. Initializing MySQL Database

/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql

12. Create a soft link file

ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock      # 直接建立软连接
    1. Edit mysqld startup script, set Basedir, DataDir directory
vim /etc/init.d/mysqld

Basedir=/usr/local/mysql
Datadir=/home/mysql

    1. Turn on the MYSQLD service and check if the service starts properly
service mysqld startnetstat -ntap | grep 3306

    1. Go to MySQL database and view all databases
      mysql>show databases;

Now that the MySQL service is deployed, see the next chapter deploying PHP services.

Lamp Deployment--two. Compiling and installing 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.