System Environment: CentOS 7.6
turn off the firewall and other security mechanisms
to check the system has no default database installed
[root @ mysqlmaster ~] # RPM -qa | grep MariaDB
MariaDB-libs-5.5.56-2.el7.x86_64
Uninstall the default database
[root @ mysqlmaster ~] # rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
Download pre-compiled binary packages
[root @ mysqlmaster ~] # wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
Extracting package
[root @ mysqlmaster ~] # tar fx mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C / usr / local
Renaming to mysql
[root @ mysqlmaster ~] # mv /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/ / usr / local / mysql
Create users and groups
[root @ mysqlmaster ~] # groupadd MySQL
[root @ mysqlmaster ~] # useradd -r -g MySQL MySQL
Mysql to write a configuration file
[root @ mysqlmaster ~] # vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/usr/local/mysql/logs/error.log
pid-file=/usr/local/mysql/mysql.pid
[client]
socket=/usr/local/mysql/mysql.sock
Then create a configuration file mentioned in the configuration file write path
[root @ mysqlmaster ~] # mkdir -p / usr / local / MySQL / the Data
[root @ mysqlmaster ~] # mkdir -p / usr / local / MySQL / logs
[mysqlmaster the root @ ~] # Touch /usr/local/mysql/logs/error.log
授权
[root@mysqlmaster ~]# chown -R mysql.mysql /usr/local/mysql/
[root@mysqlmaster ~]# chown -R mysql.mysql /etc/my.cnf
安装
[root@mysqlmaster ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
Do some additional security reinforcement
[root @ mysqlmaster ~] # / usr / local / mysql / bin / mysql_ssl_rsa_setup --basedir = / usr / local / mysql / --datadir = / usr / local / mysql / data /
copy startup scripts
[root @ mysqlmaster ~] # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改文件
[root@mysqlmaster ~]# sed -i '46c basedir=/usr/local/mysql' /etc/init.d/mysqld
[root@mysqlmaster ~]# sed -i '47c datadir=/usr/local/mysql/data' /etc/init.d/mysqld
[root@mysqlmaster ~]# sed -i '63c mysql_pid_file_path=/usr/local/mysql/data/mysqld.pid' /etc/init.d/mysqld
Start the database
[root @ mysqlmaster ~] # /etc/init.d/mysqld start
to start the database successfully!
Soft-start is provided to facilitate connection
[root @ mysqlmaster ~] # ln -s / usr / local / mysql / bin / * / usr / local / sbin /
Change Password (five or interactive tall modify password), and log success!
[Root @ mysqlmaster ~] # MySQL -e "use MySQL; the ALTER the User 'root' @ 'localhost' IDENTIFIED by '123456';"
[root @ mysqlmaster ~] # mysql -uroot -p123456
Was added to the management systemctl
CAT> << /usr/lib/systemd/system/mysqld.service the EOF
[mysqld]
[Unit]
the Description = the MySQL
the SourcePath = / etc / the init.d / mysqld
the Before shutdown.target =
[Service]
User=mysql
Type=forking
ExecStart=/etc/init.d/mysqld start
ExecStop=/etc/init.d/mysqld stop
[Install]
WantedBy=multi-user.target
EOF
Reload the configuration file services, and restart mysqld
systemctl-daemon reload
systemctl restart mysqld
View Log Launch OK
[root @ mysqlmaster ~] # journalctl -f
startup success!