Compile and install mysql5.7 on linux
This article mainly introduces about linux compilation and installation of mysql5.7, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
mysql compilation and installation
Add user
useradd -s /usr/sbin/nologin -r mysql
Download the source package and unzip it
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.21.tar.gz tar -zxf mysql-boost-5.7.21.tar.gz cd mysql-5.7.21
Install extension dependencies
yum remove mariadb-libs yum install gcc -y yum install gcc-c++ -y yum install cmake -y yum install libaio -y yum install ncurses-devel -y
Create mysql The installation directory and database storage directory
mkdir -p /data/db/mysql mkdir -p /data/log/mysql
Compile and install mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DSYSCONFDIR=/usr/local/mysql/etc \ -DMYSQL_DATADIR=/data/mysql \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_SYSTEMD=1 \ -DWITH_SSL=system \ -DWITH_ZLIB=system \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost make -j8 && make install
Check whether the installation is successful
[root@root mysql-5.7.12]# cd /usr/local/mysql/ [root@root mysql]# ls bin data include man mysql.sock.lock README support-files COPYING docs lib mysql.sock mysql-test share
New directory
mkdir -p /data/db/mysql/ mkdir -p /data/log/mysql/
Add configuration file
mkdir /usr/local/mysql/etc touch /usr/local/mysql/etc/my.cnf ln -s /usr/local/mysql/etc/my.cnf /usr/local/etc
Modify permissions
chown -R mysql:mysql /usr/local/mysql/* chown -R mysql:mysql /data/db/mysql /data/log/mysql
Generate initialization password
cd /usr/local/mysql bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/db/mysql bin/mysql_ssl_rsa_setup vim /data/log/mysql/error.log 查看初始化密码 grep 'temporary password' /data/log/mysql/error.log
Add the mysql startup service to the system service
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system mkdir -p /var/run/mysqld/ chown mysql:mysql /var/run/mysqld systemctl start mysqld service mysql start
Start mysql
service mysqld start 检查mysql启动是否正常 service mysqld status 或者 ps -ef | grep mysql 设置mysqld服务开机自启动 systemctl enable mysqld.service 检查mysqld开机自启动是否设置成功 systemctl list-dependencies | grep mysqld
Modify mysql password, and remote connection permissions
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Studytime%'; use mysql; select host, user from user; update user set host = '%' where user = 'root'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Studytime%' WITH GRANT OPTION; FLUSH PRIVILEGES;
The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
How to compile and install extended redis and swoole with php
The above is the detailed content of Compile and install mysql5.7 on linux. For more information, please follow other related articles on the PHP Chinese website!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

macOS and Linux have their own advantages in compatibility and user experience. macOS has excellent compatibility within the Apple ecosystem, and the user experience is simple and intuitive; Linux has outstanding hardware compatibility and software flexibility. The user experience varies from distribution to distribution, emphasizing personalization and control.

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.

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.

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT

Installing MySQL on macOS can be achieved through the following steps: 1. Install Homebrew, using the command /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". 2. Update Homebrew and use brewupdate. 3. Install MySQL and use brewinstallmysql. 4. Start MySQL service and use brewservicesstartmysql. After installation, you can use mysql-u
