CentOS source installation MySQL5.7

First, the installation
source installation, Source Package Name mysql-boost-5.7.27.tar.gz, this version includes boost library, path in the boost decompressed. When installed, can -DDOWNLOAD_BOOST = 1 -DWITH_BOOST = / usr / local / mysql-5.7.27 / boost / boost specified path

Second, the installation path
base path / usr / local / mysql
data file path / usr / local / mysql / data

三、安装依赖
yum -y install autoconf automake libtool cmake ncurses-devel openssl-devel lzo-devel zlib-devel gcc gcc-c++

Fourth, the add user information
adding system mysql mysql user group and
add the system sets the groupadd mysql mysql
add mysql user useradd -r -g mysql mysql (mysql After completion of the available view ID)
cut to mysql directory cd / usr / local / mysql
modify the current directory owned by mysql user chown -R mysql.mysql ./

五、配置预编译
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DCOMPILATION_COMMENT="lq-edition" -DENABLE_DTRACE=0 -DOPTIMIZER_TRACE=1 -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-5.7.27/boost/
出现如下警告
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_READLINE
-- Build files have been written to: /usr/local/mysql-5.7.27
忽略即可。

Sixth, build and install
compile make
install make install
If server memory is small, you can use the following instructions
make -j `grep processor / proc / cpuinfo | consume a lot of memory when wc -l` # compiler, a small memory may not be compiled

Seven, to initialize the database
cd / usr / local / MySQL / bin /
./mysqld --initialize --user = MySQL
get to the password, / 7Xa7Y # hN_X

Eight, open ssl function
cd / usr / local / MySQL / bin /
./mysql_ssl_rsa_setup

IX test start MySQL
cd / usr / local / MySQL / bin /
./mysqld_safe --user = MySQL
there are mistakes

mysqld_safe error:log-error set to '/var/log/mariadb/mariadb.log',however file does not exists,Create writable for you 'mysql'.

Mysql user permission is not /var/log/mariadb/mariadb.log
perform operations
mkdir / var / log / MariaDB
Touch /var/log/mariadb/mariadb.log
chown -R & lt mysql: mysql / var / log / MariaDB

The new execution ./mysqld_safe --user = mysql

execution succeed

 

Ten, start mysql service and change the password
cd / usr / local / mysql / Support-Files
./mysql.server Start

The method described above has been given, because mysql user created that use the chown -R mysql: mysql ./ configure relevant route / user / local / mysql directory, but the method should be ubuntu instruction, resulting in the installation when the database authority of a problem, the instruction should be CentOS chown -R mysql.mysql ./
herein for normal startup database, without reloading, in the following way
configuration file follows /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

Then execute the following instructions, starting a database with root privileges
CD / usr / local / MySQL / bin
./mysqld --user = root

XI, profile location
/etc/my.cnf

XII Change password
SET PASSWORD FOR 'root' @ ' %' = PASSWORD ( 'password');

XIII, adding environment variables
edit ~ / .bashrc file, vim ~ / .bashrc, add the following
Export MYSQL_HOME = / usr / local / MySQL
Export the PATH = $ the PATH: $ MYSQL_HOME / bin
execute the following command, the environment variable to take effect
source ~ / .bashrc

Fourth, run remote database connections
execute the following command
GRANT ALL PRIVILEGES ON * * TO ' root' @ '%' IDENTIFIED BY 'password' WITH GRANT OPTION;.
Refresh authority table
FLUSH PRIVILEGES;

CREATE DATABASE IF NOT EXISTS test_db default charset utf8 COLLATE utf8_general_ci;

–uroot –ppassword –Dtest_db

 

Guess you like

Origin www.cnblogs.com/youjile/p/11470208.html