For a detailed tutorial on installing Mysql5.7.19 on Centos7 in Linux, centos7mysql5.7.19
1. Download mysql
Web: https://dev.mysql.com/downloads/mysql/
2. Select the source code package and click to download the general version.
You can download it directly without logging on.
3. decompress and compile
tar -zxvf mysql-5.7.19.tar.gzcd mysql-5.7.19.tar.gz
Create a data directorymkdir -p /data/mysql
Use cmake to compile the program first. Without this command, install yum first.
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql/# This is the location of the mysql directory after compilation and installation, you can change-DMYSQL_DATADIR =/data/mysql/# To the data directory-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DSYSCONFDIR =/usr/local/mysql-5.7/conf/-packages = bytes = 1-DWITH_READLINE = 1-DMYSQL_TCP_PORT = bytes = 1-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DMYSQL_USER = mysql-DWITH_SSL = system-DWITH_ZLIB = system-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/usr/local/boost # The Boost library must be installed from MySQL 5.7.5.
After compilationmake && make install
A long wait... the installation is complete.
After the installation is complete, the path/usr/local/will contain a directory mysql, which is the path of the compilation and installation settings-
DCMAKE_INSTALL_PREFIX=/usr/local/mysql/
For the sake of security, we will create a mysql user and a mysql group and execute the following command
# Add User Group groupadd mysql # Add User mysql to user group mysqluseradd-g mysql
Grant mysql Permissions
Chown-R mysql: mysql # Add User Group groupadd mysql # Add User mysql to user group mysqluseradd-g mysql
Grant mysql Permissions
chown -R mysql:mysql mysql
4. Configure the boot direction and set the boot start
Configuration/ect/my.cnf
If my. cnf is not available, you can create a new one for your reference only.
[client]ort = 3306ocket = /tmp/mysql.sockdefault-character-set = utf8mb4[mysqld]ort = 3306ocket = /tmp/mysql.sockasedir = /usr/local/mysqldatadir = /data/mysqlid-file = /data/mysql/mysql.piduser = mysqlind-address = 0.0.0.0erver-id = 1init-connect = 'SET NAMES utf8mb4'character-set-server = utf8mb4#skip-name-resolve#skip-networkingack_log = 300max_connections = 1000max_connect_errors = 6000open_files_limit = 65535table_open_cache = 128max_allowed_packet = 4Minlog_cache_size = 1Mmax_heap_table_size = 8Mtmp_table_size = 16Mread_buffer_size = 2Mread_rnd_buffer_size = 8Mort_buffer_size = 8Mjoin_buffer_size = 8Mkey_buffer_size = 4Mthread_cache_size = 8query_cache_type = 1query_cache_size = 8Mquery_cache_limit = 2Mft_min_word_len = 4log_bin = mysql-biinlog_format = mixedexpire_logs_days = 30log_error = /data/mysql/mysql-error.loglow_query_log = 1long_query_time = 1low_query_log_file = /data/mysql/mysql-slow.logerformance_schema = 0explicit_defaults_for_timestam#lower_case_table_names = 1kip-external-lockingdefault_storage_engine = InnoDB#default-storage-engine = MyISAMinnodb_file_per_table = 1innodb_open_files = 500innodb_buffer_pool_size = 64Minnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 0innodb_purge_threads = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2Minnodb_log_file_size = 32Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120ulk_insert_buffer_size = 8Mmyisam_sort_buffer_size = 8Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1interactive_timeout = 28800wait_timeout = 28800[mysqldump]quickmax_allowed_packet = 16M[myisamchk]key_buffer_size = 8Mort_buffer_size = 8Mread_buffer = 4Mwrite_buffer = 4M
Next, execute the initialization database statement:
Note:mysql_install_db
It is no longer recommended. We recommend that you change to mysqld-initialize to complete instance initialization.
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
This step is very important. If the database is started directly without initialization, an error will be reported.
ERROR! The server quit without updating PID file (/data/mysql. pid ).
If the initialization fails or the following error is reported, you need to clear your/data/mysql directory first, because the mysql directory contains data, so the initialization is aborted.
2017-08-29T13: 39: 47.241469Z 0 [ERROR] -- initialize specified but the data directory has files in it. Aborting.2017-08-29T13: 39: 47.241536Z 0 [ERROR] Aborting
Clear and re-Initialize
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
Start mysql.
ervice mysqld start
Logon Test
/usr/local/mysql/bin/mysql -uroot -
Because of initialization--initialize-insecure
No password by default, so you don't have to enter the password to confirm it;
Assume that an error is reported during logon.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Check whether the database is successfully started.ps -ef | grep mysql
Check whether the process is started.
The empty password is not safe, so we need to set the password. The \ "root \" in the following command sets the password area. My password is set to root and can be modified on its own.
[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"root\" with grant option;"[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"root\" with grant option;"
Next, log on to test the password modification!
Summary
The above is a detailed tutorial on installing Mysql5.7.19 on Centos7 in Linux. I hope it will help you. If you have any questions, please leave a message and I will reply to you in time. Thank you very much for your support for the help House website!