1. Unzip the file
[root@localhost software]# tar -xzvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2. Modify the file
[root@localhost software]# mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
3. Check whether the library file has been deleted, and if so, delete it (it comes with the linux system)
[root@localhost mysql]# rpm -qa | grep mysql
删除
[root@localhost mysql]# rm -e –-nodeps mysql-libs-5.1.52.x86_64
4. Check whether the mysql group and user exist, if not created:
5. Add the data directory under mysql
[root@localhost mysql]# mkdir data
6. Change the combined user of all directories and folders in the mysql directory
[root@localhost /]# cd /usr/local/
[root@localhost local]# chown -R mysql mysql/
[root@localhost local]# chgrp -R mysql mysql/
[root@localhost local]# cd mysql/
[root@localhost mysql]# ls -l
total 40
drwxr-xr-x. 2 mysql mysql 4096 Aug 31 16:45 bin
-rw-r--r--. 1 mysql mysql 17987 Jun 22 22:13 COPYING
drwxr-xr-x. 2 mysql mysql 6 Aug 31 16:48 data
drwxr-xr-x. 2 mysql mysql 52 Aug 31 16:45 docs
drwxr-xr-x. 3 mysql mysql 4096 Aug 31 16:44 include
drwxr-xr-x. 5 mysql mysql 4096 Aug 31 16:45 lib
drwxr-xr-x. 4 mysql mysql 28 Aug 31 16:45 man
-rw-r--r--. 1 mysql mysql 2478 Jun 22 22:13 README
drwxr-xr-x. 28 mysql mysql 4096 Aug 31 16:45 share
drwxr-xr-x. 2 mysql mysql 86 Aug 31 16:45 support-files
8. Install and initialize the database:
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/
2017-08-31T08:50:23.910440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-31T08:50:23.910635Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' con
figuration directive.2017-08-31T08:50:24.709286Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-31T08:50:24.767540Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-31T08:50:24.892629Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6e083b8f-8e29-11e7-88b1-
005056b427be.2017-08-31T08:50:24.895674Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-31T08:50:24.896645Z 1 [Note] A temporary password is generated for root@localhost: gFamcspKm2+u
报错[ERROR] Can’t find error-message file ‘/usr/local/mysql/–datadir=/usr/local/mysql/data/share/errmsg.sys’. Check error-message file location and ‘lc-messages-dir’ con
解决:
[root@dbserver bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
2017-08-31T09:00:54.941514Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-31T09:00:56.364312Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-31T09:00:56.602211Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-31T09:00:56.668145Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e69986d2-8e2a-11e7-a335-
005056b427be.2017-08-31T09:00:56.671464Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-31T09:00:56.672453Z 1 [Note] A temporary password is generated for root@localhost: qfuqvCsHb2!.
9. Configure my.cnf
10. Start the service
[root@localhost mysql]# cd bin/
[root@localhost bin]# ./mysqld_safe --user=mysql &
[2] 10436
[root@dbserver bin]# Logging to '/var/log/mysql/mysql.log'.
2017-08-31T09:52:15.806633Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-08-31T09:52:16.292949Z mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended
11. Add the mysqld service to the boot auto-start item.
[root@localhost support-files] # cp mysql.server /etc/init.d/mysql
[root@localhost support-files] # chmod +x /etc/init.d/mysql
-- register mysql as startup Service
[root@localhost support-files] # chkconfig --add mysql
-- Check if the addition is successful
[root@localhost support-files] # chkconfig --list mysql
12. Start the service with the command:
[root@localhost bin]# service mysql start
Starting MySQL.Logging to '/var/log/mysql/mysql.log'.
ERROR! The server quit without updating PID file (/var/lib/mysql/dbserver.pid).
解决
[root@localhost mysql]# rm /etc/my.cnf
[root@localhost mysql]# /etc/init.d/mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/dbserver.err'.
SUCCESS!
[root@localhost mysql]# service mysql start
Starting MySQL SUCCESS!
13. Login to mysql
[root@localhost bin]# ./mysql -u root -p
14. Set password
mysql> set password=password("root");
Query OK, 0 rows affected, 1 warning (0.00 sec)
15. Set remote login permissions
mysql> grant all privileges on *.* to'root' @'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql> quit
Bye
At this point, the entire installation process is over.