Tutorial for Centos7 to install Mysql5.7.19 under Linux (picture)
This article mainly introduces the detailed tutorial of installing Mysql5.7.19 on Centos7 under Linux. Friends in need can refer to it
1. Download mysql
2. Select the source code package and click to download the general version
You can download it directly without logging in
3. Unzip and compile
##
tar -zxvf mysql-5.7.19.tar.gz cd mysql-5.7.19.tar.gzCreate data directory
mkdir -p / data/mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ #这个是编译安装之后的mysql目录所在地,可自行更改 -DMYSQL_DATADIR=/data/mysql/ #这个指向数据目录 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/usr/local/mysql-5.7/conf/ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=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 #从MySQL 5.7.5开始Boost库是必需安装的After compilation
make && make install A long wait....The installation will be completed after that
DCMAKE_INSTALL_PREFIX=/usr/local/mysql/Generally for security reasons, we will create a mysql user and mysql group and execute the following commands
#添加用户组 groupadd mysql #添加用户mysql 到用户组mysql useradd -g mysql mysqlGive mysql permissions
chown -R mysql:mysql mysql #添加用户组 groupadd mysql #添加用户mysql 到用户组mysql useradd -g mysql mysqlGive mysql permission
chown -R mysql:mysql mysql
4. Next configure the startup direction and set the boot startup
Configuration/ect/my.cnf, if there is no my.cnf, you can create and add it yourself, for reference only
[client] ort = 3306 ocket = /tmp/mysql.sock default-character-set = utf8mb4 [mysqld] ort = 3306 ocket = /tmp/mysql.sock asedir = /usr/local/mysql datadir = /data/mysql id-file = /data/mysql/mysql.pid user = mysql ind-address = 0.0.0.0 erver-id = 1 init-connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 #skip-name-resolve #skip-networking ack_log = 300 max_connections = 1000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 128 max_allowed_packet = 4M inlog_cache_size = 1M max_heap_table_size = 8M tmp_table_size = 16M read_buffer_size = 2M read_rnd_buffer_size = 8M ort_buffer_size = 8M join_buffer_size = 8M key_buffer_size = 4M thread_cache_size = 8 query_cache_type = 1 query_cache_size = 8M query_cache_limit = 2M ft_min_word_len = 4 log_bin = mysql-bi inlog_format = mixed expire_logs_days = 30 log_error = /data/mysql/mysql-error.log low_query_log = 1 long_query_time = 1 low_query_log_file = /data/mysql/mysql-slow.log erformance_schema = 0 explicit_defaults_for_timestam #lower_case_table_names = 1 kip-external-locking default_storage_engine = InnoDB #default-storage-engine = MyISAM innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64M innodb_write_io_threads = 4 innodb_read_io_threads = 4 innodb_thread_concurrency = 0 innodb_purge_threads = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 2M innodb_log_file_size = 32M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 ulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 [mysqldump] quick max_allowed_packet = 16M [myisamchk] key_buffer_size = 8M ort_buffer_size = 8M read_buffer = 4M write_buffer = 4MNext, execute the initialization database statement: Note
mysql_install_db is no longer recommended. It is recommended to change to mysqld –initialize to complete the instance initialization.
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqlThis step is very important. If you start the database directly without initialization, an error will be reported ERROR! The server quit without updating PID file (/data/mysql/ mysql.pid).If the initialization fails or the following error is reported, you need to clear your /data/mysql directory first. Because there is data under the mysql directory, the initialization execution 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 then re-initialize
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqlNow you can start mysql
ervice mysqld startLog in Test
/usr/local/mysql/bin/mysql -uroot -Because initialization
--initialize-insecure does not have a password by default, so you can directly confirm the password without entering it;
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)Check whether you have successfully started the database or not.
ps -ef | grep mysql Check whether the process is started
[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 in again and test if the password change is successful, it’s done!
Summarize
The above is the detailed content of Tutorial for Centos7 to install Mysql5.7.19 under Linux (picture). For more information, please follow other related articles on the PHP Chinese website!

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
