I just activated the machine. I was prepared to compile and install lnmp and found that mysql would not compile. I was a little depressed. It turns out that cmake has been used for installation in mysql since mysql 5.5. (Although the one-click installation of lnmp package and yum method are available, I don't like it very much, but I still have high customization ).
Hurry up and find a method on the Internet. record it.
First, check whether cmake is installed.
Yum install cmake
After confirmation, configure
# Adding users and changing Permissions
Groupadd mysql
Useradd-s/sbin/nologin-M-g mysql
Mkdir-p/home/mysql/
Mkdir-p/home/mysql/data/
Mkdir-p/home/mysql/log/
Chown-R mysql: mysql/home/mysql/
# Configuration
Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/home/mysql/data \
-DMYSQL_USER = mysql \
-DWITH_SSL = yes \
-DMYSQL_TCP_PORT = 3306
The above is my configuration file. For more information about other parameters, see the official documentation:
- -DCMAKE_INSTALL_PREFIX =/usr/local/mysql \ # installation directory
- -DMYSQL_UNIX_ADDR =/tmp/mysql. sock \ # Unix socket file path. Customize this path to prevent Error Reporting
- -DDEFAULT_CHARSET = gbk \ # default character
- -DDEFAULT_COLLATION = gbk_chinese_ci \ # Check characters
- -DEXTRA_CHARSETS = all \ # Install all extended character sets
- -DWITH_MYISAM_STORAGE_ENGINE = 1 \ # Install the myisam storage engine
- -DWITH_INNOBASE_STORAGE_ENGINE = 1 \ # Install the innodb Storage Engine
- -DWITH_ARCHIVE_STORAGE_ENGINE = 1 \ # Install the archive storage engine
- -DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \ # Install the blackhole storage engine
- -DWITH_MEMORY_STORAGE_ENGINE = 1 \ # Install the memory storage engine
- -DWITH_FEDERATED_STORAGE_ENGINE = 1 # Install the frderated storage engine
- -DWITH_READLINE = 1 \ # shortcut key function
- -DENABLED_LOCAL_INFILE = 1 \ # Allow Local Data Import
- -DMYSQL_DATADIR =/usr/local/mysql/data \ # database storage directory
- -DMYSQL_USER = mysql \ # database owner
- -DMYSQL_TCP_PORT = 3306 \ # Database Port
- -DSYSCONFDIR =/etc \ # MySQL configuration file
- -DWITH_SSL = yes # Database SSL
After configuration is complete
Make
Make install
5.6.12 and later, the my. default. cnf file is officially provided, so the configuration should be resolved by yourself.
After the configuration is complete, install the initial database
Chmod + w/usr/local/mysql
Chown-R mysql: mysql/usr/local/mysql
Ln-s/usr/local/mysql/lib/libmysqlclient. so.16/usr/lib/libmysqlclient. so.16
Cd/usr/local/mysql
Scripts/mysql_install_db -- user = mysql -- datadir =/home/mysql/data
Cp support-files/mysql. server/etc/init. d/mysql. server
Manual start
/Etc/init. d/mysql. server start
Change Password
/Usr/local/mysql/bin/mysqladmin-u root password 'root'
Installation Complete