Summary of several MySQL installation methods and configuration problems, and mysql installation methods
1. Install MySQL rpm package
# Download installation source [root @ localhost src] # wget https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm# installation source [root @ localhost src] # rpm-ivh mysql-community-release-el7-5.noarch.rpm
2. Install MySQL yum Tool
[Root @ localhost/] # yum install-y mysql-community-server # view the installed file path [root @ localhost/] # which mysql mysqld_safe mysqlbinlog mysqldump/usr/bin/ mysql/usr/bin/mysqld_safe/usr/bin/mysqlbinlog/usr/bin/mysqldump
To view the detailed file list contained in each installation package, you can use "rpm-ql software name" to view the file list and installation location of the current rpm package. As follows:
[root@localhost /]# rpm -ql openssl/etc/pki/tls/misc/c_hash/etc/pki/tls/misc/c_info/etc/pki/tls/misc/c_issuer/etc/pki/tls/misc/c_name/usr/bin/openssl/usr/share/doc/openssl-1.0.1e/usr/share/doc/openssl-1.0.1e/CHANGES.......
3. Install MySQL source code
# Install and compile the required software package [root @ localhost src] # yum install-y make gcc-c ++ cmake bison-devel ncurses-devel gcc autoconf automake zlib * fiex * libxml *# download source code [root @ localhost src] # wget https://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.24.tar.gz# unzip source package [root @ localhost src] # tar xvf mysql-5.6.24.tar.gz [root @ localhost src] # cd mysql-5.6.24 # compile configuration, this process will take 3 ~ 5 minutes [root @ localhost mysql-5.6.24] # cmake \-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \-DMYSQL_DATADIR =/data/mysql/data \-DSYSCONFDIR =/etc \-DWITH_MYISAM_STORAGE_ENGINE = 1 \-DWITH_INNOBASE_STORAGE_ENGINE = 1 \-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \-DMYSQL_TCP_PORT = 3306 \-DENABLED_LOCAL_INFILE = 1 \-character = 1 \-DEXTRA_CHARSETS = all \-DDEFAULT_CHARSET = utf8 \-DDEFAULT_COLLATION = utf8_gene Ral_ci # compile and install # the compilation process requires about 30 ~ 50 minutes [root @ localhost mysql-5.6.24] # make [root @ localhost mysql-5.6.24] # make install # Set MySQL users and groups [root @ localhost mysql-5.6.24] # groupadd mysql [root @ localhost mysql-5.6.24] # useradd-r-g mysql [root @ localhost mysql-5.6.24] # cd/usr/local/mysql/# Set permissions so that mysql can modify the file [root @ localhost mysql] # chown- R mysql: mysql. /[root @ localhost mysql] # chown-R mysql: mysql/data/mysql/data # initialize the database # note that the data directory set here should be the same as the directory specified by MYSQL_DATADIR [root @ localhost mysql] # scripts/mysql_install_db -- user = mysql-ldata =/data/mysql/data # restore permission settings, and modify the permissions of the corresponding directory so that mysql can modify [root @ localhost mysql] # chown-R root. /[root @ localhost mysql] # chown-R mysql data
The preceding example shows how to install MySQL in the/usr/local/mysql directory. The parameters used in this example and their meanings are as follows:
DCMAKE_INSTALL_PREFIX: indicates where to install MySQL. In this example, it will be installed in the/usr/local/mysql directory;
DMYSQL_DATADIR: the directory where MySQL data files are stored; DSYSCONFDIR: the directory where the configuration files are located;
DWITH_MYISAM_STORAGE_ENGINE: Compile the MyISAM storage engine into the service;
DWITH_INNOBASE_STORAGE_ENGINE: Compile the InnoDB Storage engine into the service; DMYSQL_UNIX_ADDR:
DMYSQL_TCP_PORT: Default port; DENABLED_LOCAL_INFILE: Specifies whether local load data execution is allowed
INFILE; DWITH_PARTITION_STORAGE_ENGINE: Compile the partition engine into the service;
DEXTRA_CHARSETS: enables the Service to support all extended character sets; DDEFAULT_CHARSET: the default character set used by the Service, which is set
UTF8; DDEFAULT_COLLATION: the default sorting rule.
There are a lot of parameters when compiling and installing MySQL, detailed meanings and descriptions of these parameters can be found on the official site: http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
The role of the installed dependency package:
Gcc/g ++: Starting from MySQL 5.6, g ++ must be used for compilation. cmake: Starting from MySQL 5.5, cmake is used for project management. cmake requires version 2.8 or later. bison: mySQL syntax parser needs to use bison for compilation; ncurses-devel: Development Kit for terminal operations; zlib: MySQL uses zlib for compression; libxml: used for XML input/output; openssl: use openssl secure socket for communication;
Dtrace: used to diagnose MySQL problems.
It is not enough to complete the above installation steps. You also need to add configuration options for MySQL and start the stop script.
Cd/usr/local/mysql/# Remove the comments in the configuration file and only display the valid grep-v "^ #" my. cnf # Put the startup script in/etc/init. cp support-files/mysql. server/etc/init. d/mysqld # add mysql as the system service chkconfig -- add mysqldservice mysqld start # at this time, the root user of MySQL has no password, set the password/usr/local/mysql/bin/mysql-u root-h 192.168.146.150-p # because the password has not been set, press Enter. # Set the root user's the password is 888888 set password = password ('20140901 '); # Enter quit to exit quit after setting
Appendix: Summary of problems during installation
1.-bash: mysql: command not found
Because the mysql command path is under/usr/local/mysql/bin, the system cannot find this command when you directly use the mysql command under/usr/bin.
Solution: Use the following command to create a link.
ln -s /usr/local/mysql/bin/mysql /usr/bin
2. Starting MySQL .. The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com. pid ).
Solution:
Modify datadir in/etc/my. cnf to point to the correct mysql database file directory
3. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)
Solution:
Create a new link or add the-S parameter to mysql to point out the location of mysql. sock.
ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock/usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock
The above is a summary of several MySQL installation methods and configuration issues. I hope to help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!