Install MySQL source code and mysql source code
Install mysql
Create mysqlData Directory
Mkdir-p/usr/local/mysql -- installation directory mkdir-p/usr/local/mysql/data --- data directory
Create mysqlUsers and groups
groupadd mysqluseradd -r -g mysql mysql
Install plug-ins
yum -y install gcc gcc-c++ autoconf bison cmake automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
Compile and install
Wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz
cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci
makemake install
For specific options, see mysql Official Website: http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql // installation directory
-DINSTALL_DATADIR =/usr/local/mysql/data // database storage directory
-DDEFAULT_CHARSET = utf8 // use the utf8 character
-DDEFAULT_COLLATION = utf8_general_ci // check the character
-DEXTRA_CHARSETS = all // install all extended character sets
-DENABLED_LOCAL_INFILE = 1 // allow local data import
-DINSTALL_SBINDIR = mysqlid directory
-DSYSCONFDIR = my. cnf configuration file directory
-DINSTALL_PLUGINDIR = plug-in Directory
-DINSTALL_MANDIR = directory of the manual File
-Dinstall_1_dir = shared data directory
-DINSTALL_LIBDIR = library directory
-DINSTALL_INCLUDEDIR = header installation directory
-DINSTALL_INFODIR = information document directory
Storage engine parameters (-DWITH indicates enabled,-DWITHOUT indicates disabled. mysql supports MyISAM, MERGE, MEMORY, CSV by default, and does not need to be declared during compilation ):
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_FEDERATED_STORAGE_ENGINE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
Grant mysqlUser Permissions
chown -R mysql:mysql /usr/local/mysql
Create databases and tables that come with the System
Cd/usr/local/mysqlscripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysqlmysql_install_db script is generated mySQL authorization table. It does not overwrite the existing MySQL authorization table and does not affect any other data. All Database-related files are generated by default in the/usr/local/mysql/data path mv/usr/local/mysql/my. cnf/etc/my. cnfchown-R mysql: mysql/usr/local/mysql
Configure mysqlStart the service
Go to the source package file cp support-files/mysql. server/etc/init. d/mysqlchmod + x/etc/init. d/mysql -- Grant the file executable permission chkconfig mysql on -- configure mysql to automatically start service mysql start -- start MySQL
Configure Environment Variables
To directly call the mysql command, you need to configure the environment variable vim/etc/profile to add export PATH =/usr/local/mysql/bin at the end of the/etc/profile file: $ PATH: make the environment variable take effect immediately. source/etc/profile
Set mysql rootUser Password
By default, the PASSWORD of the mysql root user is empty after installation. mysql-uroot --- log on to set password = PASSWORD ('root'); -- SET the root PASSWORD to run only local access use mysqlselect user by default, host from user where user = 'root'; GRANT the root remote connection permission, and use grant all privileges on * in the production environment with caution *. * TO 'root' @ '%' identified by 'root' with grant option;
Create backup user
grant reload,lock tables,replication client,create tablespace,super on *.* to 'backup'@'%' identified by 'backup';
Firewall Configuration
Port 3306 is disabled by default, enable port 3306 vim/etc/sysconfig/iptables and add the following content to the end of-a input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT:-a input- m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT restart Firewall service iptables restart
To modify the centos7 operating system firewall, you must:
The method for adding a port to Firewalld is as follows:
Firewall-cmd -- zone = public -- add-port = 3306/tcp -- permanent
Firewall-cmd -- reload
Summary
If you change. the default path of sock. If you need to log on to the local machine, you must configure socket in the [client]. The actual business system needs to separate the log file and data file from the disk, which can be stored in my. cnf file configuration.
Note: Author: pursuer. chen Blog: http://www.cnblogs.com/chenmh All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly give the link at the beginning of the article. Welcome to discussion |