Home >Operation and Maintenance >Linux Operation and Maintenance >Graphic tutorial for installing MySQL5.6 in Linux environment
How to install mysql under Linux: first set up the Linux environment; then install the dependency package and cmake compilation tool; then upload the MySQL source code package, decompress, compile and install; finally grant permissions to the MySQL user.
Recommended related mysql video tutorials: "mysql introductory video tutorial"
1. First set up In 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.
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,
yum install -y cmake ncurses-devel4. Compile and install MySQLUpload the MySQL source package, decompress it, compile and installCreate User
useradd -s /usr/sbin/nologin mysqlCreate database storage directory
mkdir /data
tar -zxf mysql-5.6.36.tar.gz
cd ./mysql-5.6.36
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=mysqlParameter 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运行用户Installation:
make && make install
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /dataCreate configuration file:
cp support-files/my-default.cnf /etc/my.cnfSet environment variables:
echo'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile source!$Create MySQL service startup script
cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqldModify the MySQL installation directory and data directory in the startup script
vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/dataAdd boot startup
chkconfig mysqld onInitialize the database
/usr/local/mysql/scripts/mysql_install_db--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data--user=mysqlInitialize the security configuration
mysql_secure_installationSet the root password, and generally select yes for other options5. At this step, the database has been installed and you can Execute script to start and stop database
service mysqld restart
The above is the detailed content of Graphic tutorial for installing MySQL5.6 in Linux environment. For more information, please follow other related articles on the PHP Chinese website!