Home > Database > Mysql Tutorial > body text

Graphical tutorial on compilation and installation of MySQL5.6 in Linux environment

黄舟
Release: 2017-07-18 15:20:06
Original
1705 people have browsed it

This article mainly introduces the notes of compiling and installing MySQL5.6 in the Linux environment. Friends who need it can refer to it

1. First, set up the Linux environment. I am using redhat enterprise 6.5. , and it is recommended that the disk be divided into logical volumes to facilitate later expansion work.

2. After the environment is set up, we have to prepare the MySQL installation file. Until now, mysql is still free and open source and can be downloaded directly from the official website. You can visit the official website to download by yourself,





## Of course, you need to register before downloading An Oracle account, and then select the community free version to download.

3. Install dependency packages and cmake compilation tool


yum install -y cmake ncurses-devel
Copy after login

4. Compile and install MySQL

Upload the MySQL source package and decompress it. Compile and install

Create user


useradd -s /usr/sbin/nologin mysql
Copy after login

Create database storage directory

mkdir /data

Unzip

tar -zxf mysql-5.6.36.tar.gz

cd ./mysql-5.6.36

Compile


cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-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=/data -DMYSQL_USER=mysql
Copy after login

Parameter description:

##

-DCMAKE_INSTALL_PREFIX 数据文件存放目录
-DMYSQL_UNIX_ADDR  sock文件路径
-DDEFAULT_CHARSET  默认字符集
-DDEFAULT_COLLATION 默认字符校对
-DWITH_EXTRA_CHARSETS 扩展字符支持 默认all
-DWITH_storage_STORAGE_ENGINE 存储引擎的支持,默认支持MyISAM,MERGE,MEMORY,CVS存储引擎
-DENABLED_LOCAL_INFILE=1 启用加载本地数据
-DMYSQL_DATADIR  数据存放目录
-DMYSQL_USER    mysql运行用户
Copy after login

Installation:

make && make install

Grant permissions to the MySQL user

chown -R mysql:mysql /usr/local/mysql/

chown -R mysql:mysql /data
Copy after login

Create configuration file:

cp support-files/my-default.cnf /etc/my.cnf
Copy after login

Set environment variables:

echo'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile
source!$
Copy after login

Create MySQL service startup script

##
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
Copy after login

Modify MySQL in the startup script Installation directory and data directory

vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data
Copy after login

Add startup

chkconfig mysqld on
Copy after login

Initialize database

/usr/local/mysql/scripts/mysql_install_db--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data--user=mysql
Copy after login

Initialize security configuration

mysql_secure_installation
Copy after login

Set the root password, and generally select yes for other options

5. Proceed to this step database The installation has been completed. You can execute the script to start and stop the database

service mysqld restart
Copy after login

The above is the detailed content of Graphical tutorial on compilation and installation of MySQL5.6 in Linux environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!