Home >Database >Mysql Tutorial >How to install mysql5.6 from centos source code
## The operating environment of this article: Centos6.9 system, mysql5. Version 6, Dell G3 computer.How to install mysql5.6 from centos source code: 1. Download the source code package; 2. Pass "[root@localhost ~]# tar zxvf mysql-5.6.41.tar.gz [root@localhost... "Wait for the command to compile and install mysql.
centos source code installation method for mysql5.6
Mysql version introductionWhen preparing to install MySQL, please decide which version and release format to use ( binary or source). First, decide whether to install a development version or a General Availability (GA) version. Development versions have the latest features but are not recommended for production use. Ga release, also called production or stable release, means for production use. We recommend using the latest GA version.
The naming scheme in MySQL 5.6 uses a release name consisting of three numbers and an optional suffix; for example, mysql-5.6.1-m1. The numbers in the release name are explained as follows:
https://dev.mysql.com/downloads/
## Recommended study: "
mysql video tutorial[root@localhost ~]# /etc/init.d/iptables stopiptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] [root@localhost ~]# setenforce 0setenforce: SELinux is disabled
2. Uninstall mysql-server and mysql in rpm
[root@localhost ~]# rpm -qa | grep mysqlmysql-libs-5.1.73-8.el6_8.x86_64 如果安装了mysql-server使用rpm -e命令将其卸载
3. Install mysql dependency package
[root@localhost ~]# yum install -y cmake gcc gcc-c++ ncurses-devel bison zlib openssl
4. Create mysql user and related folders
[root@localhost ~]# groupadd msyql[root@localhost ~]# useradd -g mysql -s /sbin/nologin mysql[root@localhost ~]# mkdir -p /public/mysql/data
Compile and install mysql
[root@localhost ~]# tar zxvf mysql-5.6.41.tar.gz [root@localhost mysql-5.6.41]# cd mysql-5.6.41 [root@localhost mysql-5.6.41]# cmake \ -DCMAKE_INSTALL_PREFIX=/public/mysql \ -DINSTALL_DATADIR=/public/mysql/data \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DSYSCONFDIR=/public/mysql [root@localhost mysql-5.6.41]# make && make install
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装路径 -DMYSQL_DATADIR=/usr/local/mysql/data \ #数据文件存放位置 -DSYSCONFDIR=/etc \ #my.cnf路径 -DWITH_MYISAM_STORAGE_ENGINE=1 \ #支持MyIASM引擎 -DWITH_INNOBASE_STORAGE_ENGINE=1 \ #支持InnoDB引擎 -DWITH_MEMORY_STORAGE_ENGINE=1 \ #支持Memory引擎 -DWITH_READLINE=1 \ #快捷键功能(我没用过) -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ #连接数据库socket路径 -DMYSQL_TCP_PORT=3306 \ #端口 -DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据 -DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装支持数据库分区 -DEXTRA_CHARSETS=all \ #安装所有的字符集 -DDEFAULT_CHARSET=utf8 \ #默认字符 -DDEFAULT_COLLATION=utf8_general_ci
Post-installation optimization operations
[root@localhost mysql-5.6.41]# chown -R mysql:mysql /public/mysql \ #修改msyql安装目录的属主与属组 [root@localhost mysql-5.6.41]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost ~]# echo "PATH=$PATH:/public/mysql/bin" > /etc/profile.d/mysql.sh [root@localhost ~]# source /etc/profile.d/mysql.sh [root@localhost ~]# chkconfig mysqld on \ #开机自启 [root@localhost ~]# vim /public/mysql/my.cnf [mysqld] basedir = /public/mysql datadir = /public/mysql/data port = 3306 server_id = 11 socket = /tmp/mysql.sock sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#my.cnf文件优先顺序[root@localhost ~]# mysql --help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/my.cnf /etc/mysql/my.cnf /public/mysql/my.cnf ~/.my.cnf
Initialize the database and set the password
[root@localhost ~]# /public/mysql/scripts/mysql_install_db --user=mysql --basedir=/public/mysql --datadir=/public/mysql/data \ #初始化数据库 [root@localhost ~]# mysqladmin -u root password 'Aa123456' \ #设置root密码(需先启动mysql)
#启动、停止、重启、状态 [root@localhost ~]# /etc/init.d/mysqld start [root@localhost ~]# /etc/init.d/mysqld stop [root@localhost ~]# /etc/init.d/mysqld restart [root@localhost ~]# /etc/init.d/mysqld status [root@localhost ~]# netstat -utpln | grep mysqld #登录mysql [root@localhost ~]# mysql -u root -pAa123456 \ #-p后面的密码不要有空格
The above is the detailed content of How to install mysql5.6 from centos source code. For more information, please follow other related articles on the PHP Chinese website!