Install MySQL in CentOS 6.7
My machine: CentOS 6.7 64-bit (minimal installation)
Installed MySQL: MySQL 5.6
The installation process is full of ups and downs ...... (Lack of practice)
Download
Use a non-compiled Binary Package
[root@bogon ~]# cd /usr/local/src[root@bogon src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
The link here may be invalid. You can go to http://mirrors.sohu.com/mysql/to find the desired region, see the desired version of mysql, and select the appropriate package to download.
-bash: wget: command not found
[root@bogon src]# yum -y install wget[root@bogon src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
Initialization
[root@bogon src]# tar zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz[root@bogon src]# useradd -s /sbin/nologin -M mysql[root@bogon src]# mv mysql-5.6.29-linux-glibc2.5-x86_64 /usr/local/mysql[root@bogon src]# cd /usr/local/mysql[root@bogon mysql]# mkdir -p /data/mysql[root@bogon mysql]# chown -R mysql /data/mysql[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql --datadir=data/mysql
- -The user defines the owner of the database.-datadir defines the database installation path.
- The last step here is a problem, which leads to an error when I start MySQL. The solution will be provided later.
If an error occurs, check whether the downloaded package is suitable.
-Bash:./scripts/mysql_install_db:/usr/bin/perl: bad interpreter: No file or directory
In addition to downloading packages, it may be caused by other reasons
[root@bogon mysql]# yum -y install perl perl-devel[root@bogon mysql]# yum -y install libaio
[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql --datadir=data/mysql[root@bogon mysql]# echo $?0
Echo $? It is used to check whether the previous command is successfully executed. If it is 0, it indicates normal (remember the C language return 0)
Configuration
[Root @ bogon mysql] # cd support-files/[root @ bogon support-files] # lsbinary-configure my-default.cnf mysql-log-rotatemagic mysqld_multi.server mysql. server [root @ bogon support-files] # cp my-default.cnf/etc/my. cnfcp: Indicates whether to overwrite "/etc/my. cnf "? Y [root @ bogon support-files] # cp mysql. server/etc/init. d/mysqld [root @ bogon support-files] # vim! $
vim /etc/init.d/mysqld-bash: vim: command not found
[root@bogon support-files]# yum -y install vim*[root@bogon support-files]# vim /etc/init.d/mysqld
Modify the following content in the/etc/init. d/mysqld file:
basedir=/usr/local/mysqldatadir=/data/mysql
Basedir: MySQL installation path datadir: MySQL database file installation path
Start
[root@bogon support-files]# chkconfig --add mysqld[root@bogon support-files]# chkconfig mysqld on[root@bogon support-files]# /etc/init.d/mysqld start
If it cannot be started, I will be stuck here for a long time and have tried various solutions ......
Starting MySQL... ERROR! The server quit without updating PID file (/data/mysql/bogon.pid).
[root@bogon support-files]# cd /data/mysql[root@bogon mysql]# lsauto.cnf bogon.err ibdata1 ib_logfile0 ib_logfile1[root@bogon mysql]# vi bogon.err
View error logs in/data/mysql
Later I learned that after the minimal installation of the CentOS Operating System (other installation methods should be the same), there will be a "my" in the/etc directory. cnf: You need to rename the file to another name or delete it. Otherwise, the file will interfere with the correct configuration of MySQL installed in the source code, resulting in a failure to start.
Then I deleted my. cnf and copied a my-default.cnf again.
[Root @ bogon mysql] # cd/etc/[root @ bogon etc] # ls [root @ bogon etc] # rm my. cnfrm: whether to delete a common file "my. cnf "? Y [root @ bogon etc] # cd/usr/local/mysql/[root @ bogon mysql] # cd support-files/[root @ bogon support-files] # lsbinary-configure my-default.cnf mysql-log-rotatemagic mysqld_multi.server mysql. server [root @ bogon support-files] # cp my-default.cnf/etc/my. cnf [root @ bogon support-files] # cd/usr/local/mysql/
Execute Command
./scripts/mysql_install_db --user=mysql --datadir=data/mysql --basedir=usr/local/mysql
FATAL ERROR: Could not find my-default.cnf
Wrong command ......
[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql/
Is this different from the previous one?
It seems that you have to edit the configuration file. In my/etc/my. cnf file, there is nothing except comments .....
[root@bogon mysql]# vi /etc/my.cnf
Comment out the comment, and fill in the filled content
Next, try again.
[root@bogon mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql[root@bogon mysql]# service mysqld startStarting MySQL.. SUCCESS![root@bogon mysql]# ps aux|grep mysqlroot 3900 0.0 0.1 11304 1500 pts/2 S 06:03 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/bogon.pidmysql 4127 0.1 44.8 1011200 454300 pts/2 Sl 06:03 0:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/bogon.err --pid-file=/data/mysql/bogon.pid --socket=/tmp/mysql.sock --port=3306root 4153 0.0 0.0 103316 896 pts/2 S+ 06:19 0:00 grep mysql