MySQL is a very popular relational database management system that is widely used in various applications and websites. Although MySQL can be installed on various operating systems using binary installation packages, the source code installation of MySQL can be customized and configured as needed, and is also a necessary skill for Linux system administrators. This article will introduce how to install MySQL 5.6 on CentOS 7 using source code.
- Preparation
Before starting to install MySQL 5.6, we need to make some preparations. First, make sure your system is up to date:
sudo yum update
Install the tools needed to compile MySQL:
sudo yum groupinstall "Development Tools" sudo yum install cmake ncurses-devel bison
- Download the MySQL 5.6 source code
From MySQL Download the source code of MySQL 5.6 from the official website (https://dev.mysql.com/downloads/mysql/5.6.html). Select the file in .tar.gz format to download and save to your preferred location.
- Extract the source code
Open the directory in the terminal and run the following command to decompress the file (the file name may be different here):
tar -zxvf mysql-5.6.50.tar.gz
Enter the decompressed mysql-5.6.50 directory:
cd mysql-5.6.50
- Configure MySQL 5.6
Run the following command to configure:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=yes
These parameters The meaning is as follows:
- CMAKE_INSTALL_PREFIX: The directory where MySQL will be installed.
- MYSQL_DATADIR: The storage directory for MySQL data files.
- SYSCONFDIR: The storage directory for MySQL configuration files.
- WITH_INNOBASE_STORAGE_ENGINE: Enable InnoDB storage engine.
- WITH_MYISAM_STORAGE_ENGINE: Enable the MyISAM storage engine.
- WITH_READLINE: Enable command line editing function.
- ENABLED_LOCAL_INFILE: Enable local file import function.
- WITH_EXTRA_CHARSETS: Enable all character sets.
- DEFAULT_CHARSET: Default character set.
- DEFAULT_COLLATION: Default collation.
- WITH_SSL: Enable SSL support.
After the configuration is completed, you can check whether CMake successfully generated a suitable Makefile.
- Compile and install MySQL 5.6
Use the following commands to compile and install:
make sudo make install
These commands will compile the MySQL 5.6 source code into an executable file, and install them into the /usr/local/mysql directory.
- Initialize MYSQL
After installing MySQL, use the following command to initialize MySQL:
sudo /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
This command will create the necessary files and folder, ready to start the MySQL service.
- Running MySQL 5.6
The MySQL service can now be started. Use the following command to start MySQL:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
This command starts MySQL and runs in the background. It also ensures that MySQL automatically restarts in the event of an unexpected shutdown.
- Configuring MySQL 5.6
After completing the source code installation of MySQL, we need to modify the MySQL default configuration to better meet our needs. We need to modify the following options in the MySQL configuration file:
- bind-address: The bound IP address or host name.
- port: The port used by the MySQL service.
- max_connections: The maximum number of connections allowed.
- query_cache_size: Query cache size.
- innodb_buffer_pool_size: The size of the InnoDB buffer pool.
Open the MySQL configuration file my.cnf:
sudo vi /etc/my.cnf
In this file, find the options that need to be modified and make changes. For example, to change the port number to 3307, you can add the following line:
[mysqld] port=3307
You can add other options like this:
[mysqld] port=3307 bind-address=0.0.0.0 max_connections=200 query_cache_size=128M innodb_buffer_pool_size=256M
After modifying the MySQL configuration file, remember to restart the MySQL service.
- Log in to MySQL 5.6
Use the following command to log in to MySQL:
mysql -u root -p
This command will prompt you for your password. After entering the password for the MySQL root account, you will enter the MySQL shell prompt. MySQL 5.6 has now been successfully installed and is ready to be used.
Conclusion
This article introduces the detailed steps to install MySQL on CentOS 7 using MySQL 5.6 source code. A source installation gives you more configuration options for MySQL and allows you to customize it if needed. Source code installation is also a basic skill for Linux system administrators. Follow the steps in this article, and always remember to back up your data before operating on MySQL.
The above is the detailed content of mysql 5.6 source code installation. For more information, please follow other related articles on the PHP Chinese website!

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

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


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

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
