Centos 6.4source code installation mysql-5.6.28.tar.gz tutorial, centos6.4mysql5.6
Mysql5.6.28 installation tutorial
1、before installing mysql-5.6.28.tar.gz, firstInstall the compiling environment
Copy codeThe Code is as follows: yum-y install gcc-c ++ gcc-g77 autoconf automake zlib * fiex * libxml * ncurses-devel libmcrypt * libtool-ltdl-devel * make cmake
2,Compile and install mysql
2.1 Add a user
groupadd mysql useradd -g mysql mysql
2.2 compile and install
Tar-zxvf mysql-5.6.28.tar.gz # By default is installed on the/usr/local/mysql cd mysql-5.6.28 cmake.-LH (compiled using the default properties) make & make install
2.3.1 set compilation Parameters
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_READLINE=1 \ -DMYSQL_UNIX_ADDR=/tmp/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;
2.3.2 full version
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_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/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;
2.4 change the owner of the mysql installation directory.
Chown-R mysql: mysql/usr/local/mysql # Grant write permission to mysql users (default)
3,Initialize Database
cd /usr/local/mysql/scripts ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
4. SetCopy the mysql configuration file to/etc/my. cnf
# Use the default configuration file cd/usr/local/mysql/support-files cp my-default.cnf/etc/my. cnf # modify the configuration file and add the following content # socket is applicable to communication. Be sure to add # The socket location and mysql-DMYSQL_UNIX_ADDR =/tmp/mysql in cmake. sock path. The socket path address must be the same as the previous address (otherwise, mysql service cannot be started normally .) basedir =/usr/local/mysql datadir =/usr/local/mysql/data pid-file =/usr/local/mysql/data/mysql. pid user = mysql socket =/tmp/mysql. sock
5. Add the mysql service to the system service andSet to enable auto-start
Cd/usr/local/mysql/support-files # register cp mysql. server/etc/rc. d/init. d/mysql # Let chkconfig manage mysql service chkconfig -- add mysql # Start chkconfig mysql on
6,Start Mysql Service
Service mysql start # verify that mysql is successfully started. netstat-ant | grep 3306
7,Configure the mysql user and change the root password
After Mysql is started successfully, the root user has no password by default. We need to set the root password.
Before setting the root password, set the PATH to directly call mysql and other commands in/usr/local/mysql/bin.
Modify the/etc/profile file and add it to the end of the file.
PATH=/usr/local/mysql/bin:$PATH export PATH
Close the file and run the following command to make the configuration take effect immediately
Source/etc/profile
How to change the root user password 1:
# Change 'new-password' to your own password/usr/local/mysql/bin/mysqladmin-u root password 'new-password'
How to change the root user password 2:
Now, refer to the blog where the address is http://www.bkjia.com/article/102820.htm
Log on to mysql as a root user:
# Enter the password [root @ VM_13_53_centos support-files] # mysql-uroot-p Enter password: Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 3 Server version: 5.6.28 Source distribution Copyright (c) 2000,201 5, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of Oracle Corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql>
To set remote access for the root user, run
# Change the following 'Password' to your own password mysql> grant all privileges on *. * TO 'root' @ '%' identified by 'Password' with grant option; mysql> flush privileges;
9,Disable firewall,Prevent remote connection failure
1) takes effect after restart
Enable: chkconfig iptables on
Close: chkconfig iptables off
2) takes effect immediately
Enable: service iptables start
Disable: service iptables stop
3) Open Port 3306
vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT service iptables restart
10,Change the encoding to prevent garbled characters
Show variables like 'character %'
Modify the etc/my. cnf file of mysql
[client] default-character-set=utf8 [mysqld] character-set-server=utf8 [mysql] default-character-set=utf8
11. PossibleError
Question 1:Starting MySQL .. The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com. pid ).
Solution:
Modify/etc/my. cnf to add socket Configuration
Question 2: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
12. ReferenceBlog posts
1. http://www.bkjia.com/article/102799.htm
2. http://www.bkjia.com/article/102807.htm
Mysql download: https://pan.baidu.com/s/1jHXOzMe
Highlights: mysql installation tutorials for different versions mysql5.7 installation tutorials for various versions mysql5.6 installation tutorials
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.