If problems occur, please turn to the very bottom, there will be possible solutions
1. Download
wget: https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
2, mounted to the mysql / usr / local / the MySQL
# extracting
the tar--xvf MySQL 5.7.23-Linux-glibc2.12-x86_64.tar.gz
# moved
mv-MySQL 5.7.23-Linux-glibc2.12-the x86_64 / usr / local /
# rename
mv /usr/local/mysql-5.7.23-linux-glibc2.12-x86_64 / usr / local / mysql
3. New data directory
mkdir / usr / local / mysql / data
. 4, the new user mysql, mysql user group
# mysql user set
the groupadd MySQL
# MySQL user
the useradd -g MySQL MySQL
. 5, the / usr / local / mysql group belongs to the owner and MySQL
chown -R & lt mysql.mysql / usr / local / mysql
. 6, the configuration (the solid column of success will At the password root @ localhost: q9fSP9uRDa-R)
/ usr / local / MySQL / bin / MySQL --basedir the mysql_install_db --user = = / usr / local / MySQL / --datadir = / usr / local / MySQL / Data
# if error, then use the following commands:
/ usr / local / mysql / bin / mysqld --user = mysql --basedir = / usr / local / mysql / --datadir = / usr / local / mysql / data --initialize
or
bin / mysqld --initialize --user = mysql = --basedir / usr / local / MySQL --datadir = / usr / local / MySQL / Data --lc_messages_dir = / usr / local / MySQL / Share --lc_messages the en_US =
7. The added my.cnf (5.7.23 no my.cnf needs its own default configuration)
VI /etc/my.cnf
[mysql]
# mysql client set the default character set
default-character-sET = UTF8
Socket = / var / lib / mysql / mysql.sock
[mysqld]
#skip Resolve--name
# 3306 port disposed
port = 3306
Socket = / var / lib / MySQL / mysql.sock
# Set mysql installation directory
basedir = / usr / local / mysql
storage directory data # Set mysql database
DATADIR = / usr / local / mysql / Data
# maximum number of connections
max_connections = 10000
# character set the server uses the default is 8-bit coded character set latin1
character-set-server = utf8
default storage engine # when used to create a new table
default-storage-engine INNODB =
# =. 1 lower_case_table_name
the max_allowed_packet = 16M
8. the boot
added services
cp / usr / local /etc/init.d/mysql /mysql/support-files/mysql.server
# boot from Kai
chkconfig mysql ON
# open
Service Start mysql
9. Log mysql to change the password (before the actual column of password)
mysql -u root -p
Change password
set password = password ( 'password')
10 allows remote access
MySQL -u the root -p
use MySQL;
update user set host='%' where user = 'root';
flush privileges;
eixt;
***************** problems and possible solutions *******************
Initialization binary install mysql appear: Installing MySQL system tables ... / usr / local / mysql / bin / mysqld: error while loading shared
The reason: lack of library files libaio
Solution: yum install libaio * -y
出现:Starting MySQL.2019-11-13T01:52:46.980719Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/usr/local/mysql[FAILED]bp1629dthbt44srhzw93Z.pid).
solution
1、mkdir /var/log/mariadb
2、touch /var/log/mariadb/mariadb.log
3、chown -R mysql:db /var/log/mariadb/
4、chown -R mysql:db /var/log/mariadb/mariadb.log
5、chown -R mysql:mysql /var/log/mariadb/mariadb.log
出现:mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
solution
1, mkdir / var / lib / mysql
2, chmod 777 / var / lib / mysql
Appearance: -bash: MySQL: the Command not found
solution
1、ln -s /usr/local/mysql/bin/mysql /usr/bin
出现:You must reset your password using ALTER USER statement before executing this statement
solution:
ALTER USER USER() IDENTIFIED BY '密码';