How to compile Mysql5.7.11 through Systemd
May 29, 2023 pm 06:46 PM
MySQL 5.7 main features:
Native support for Systemd Better performance: for multi-core CPUs, solid-state drives, The lock has a better optimized InnoDB storage engine and a more robust replication function: replication brings no data loss at all, and traditional financial customers can also choose to use the MySQL database. In addition, GTID online smooth upgrade also becomes possible with a better optimizer: the significance of optimizer code reconstruction will bring huge improvements in this version and subsequent versions, Oracle officials are solving the biggest problem before MySQL native JSON type Support better geographical information service support: InnoDB natively supports geographical location types, supports GeoJSON, and GeoHash features. New sys library: This will be the most frequently accessed library by DBAs in the future. MySQL 5.7 has been added to OneinStack as a database option - lnmp In the installation tool
Install dependency packages
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
Download the mysql source package
There are two versions of the source package: mysql- 5.7.11.tar.gz does not come with the boost library and needs to be downloaded by yourself.
mysql-boost-5.7.11.tar.gz comes with the boost library. It is recommended to download it in the root directory after decompression. wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
curl -O http://cdn.mysql .com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
tar -zxf mysql-boost-5.7.11.tar.gz
cd mysql-5.7 .11
Compile
Generate makefile "
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/ mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -D EXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ [Character set] -DDEFAULT_COLLATION=utf8_general_ci \ [Collation rules must be present, otherwise it will be difficult to initialize the database] -DDOWNLOAD_BOOST=1 \ [The Boost library is required starting from MySQL 5.7.5] -DWITH_BOOST=/root/mysql-5.7.11/ boost \ -DWITH_SYSTEMD=1 [Support Systemd] Adding -DWITH_SYSTEMD=1 can use systemd to control the mysql service. Systemd is not enabled by default.
Thenmake -j 2 && make install
mysql will be installed to the /usr/local/mysql path and wait slowly...
Configure MySQL
Add mysql user and group
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
Modify /usr/local/mysql permissions
chown -R mysql:mysql /usr/local/mysql
Create mysql PID default directory
In mysqld.service, the default pid file is assigned to the /var/run/mysqld/ directory, but the directory is not created in advance, so the directory must be created manually and the permissions Assigned to the mysql user. mkdir -p /var/run/mysqldchown mysql:mysql /var/run/mysqld
mysql The default location of the three running files
log : /var/log/mysqld.logpid : /var/run/mysqld/mysqld.pidsock : /tmp/mysql.sock
Copy my.cnf and mysqld.service
cp support-files/my-default.cnf /etc/my.cnf
mysql 5.7 by default installs the mysqld.service (/usr/local/mysql/) file to usr/lib/systemd in the mysql installation directory /system/, copy mysqld.service to the /usr/lib/systemd/system/ directory [root@localhost]/usr/local/mysql#cp usr/lib/systemd/system/mysqld.service /usr /lib/systemd/system
Add environment variables
— Edit the /etc/profile file and add the following two lines at the end— “
vim /etc/profile
PATH=/usr/local/mysql/bin:$PATH export PATH
source /etc/profile
Initialization Passwordless mysql database
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/ databin/mysql_ssl_rsa_setup
The following content appears, initialization is successful 2016-02-22T03:56:27.254356Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the –initialize-insecure option.
-–initialize will generate a random password (saved in ~/.mysql_secret), while -–initialize-insecure will not generate a password. When setting the password in the MySQL security configuration wizard mysql_secure_installation, you can freely select the mysql password level .
-–There cannot be data files in the datadir target directory.
The previous version initialization program mysql_install_db is under /usr/local/mysql/script and will be removed in the future. Mysqld will be used instead. The deprecated mysql5.7 is placed in /usr/local/ mysql/bin directory.
Start mysql
systemctl start mysqld.service
systemctl status mysqld.service
Run the MySQL security configuration wizard mysql_secure_installation Set password , the mysql service can only be executed after starting
a) Set a password for the root user b) Delete the anonymous account c) Cancel the remote login of the root user d) Delete the test library and access rights to the test library e) Refresh the authorization table Make the modification effective[root@localhost mysql]# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password. [使用空密碼連接到MySQL]
VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?[VALIDATE密碼插件可以被用來測(cè)試密碼 并提高安全性。你是否想設(shè)置VALIDATE密碼插件?]
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy: [有三種級(jí)別的密碼驗(yàn)證策略:]
LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file [最小長度> = 8 中等長度> = 8,數(shù)字,大小寫混合和特殊字符 最長長度> = 8,數(shù)字,混合大小寫,特殊字符和字典文件]
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 [請(qǐng)輸入0 =低,1 =中2 =強(qiáng):0] Please set the password for root here. [請(qǐng)?jiān)谶@里設(shè)置root用戶的密碼。]
New password: [新密碼:]
Re-enter new password: [重新輸入新密碼:]
Estimated strength of the password: 25 [密碼的估計(jì)強(qiáng)度:25] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y [您是否希望繼續(xù)與提供的密碼(按y | Y表示是,因?yàn)闆]有任何其他鍵):Y?] … Failed! Error: Your password does not satisfy the current policy requirements [ … 失敗!錯(cuò)誤:您的密碼不符合當(dāng)前的要求]
New password:
Re-enter new password:
Estimated strength of the password: 50 [密碼的估計(jì)強(qiáng)度:50] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. [默認(rèn)情況下,MySQL安裝有一個(gè)匿名用戶, 允許任何人登錄到MySQL.]
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y [刪除匿名用戶?] Success. [成功。]
Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. [通常情況下,Root 只允許其進(jìn)行’localhost'(本地) 連接 。]
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n [禁止遠(yuǎn)程root登錄?]
...omitting. [省略]。] By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. [默認(rèn)情況下,MySQL帶有一個(gè)名為“測(cè)試”數(shù)據(jù)庫,任何人都可以訪問。這也是僅用于測(cè)試,并且應(yīng)該移動(dòng)到生產(chǎn)之前被刪除環(huán)境。]
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n [刪除測(cè)試數(shù)據(jù)庫和訪問權(quán)限?]
... omitting. [ ...省略。] Reloading the privilege tables will ensure that all changes made so far will take effect immediately. [刷新授權(quán)表以確保所有的變化取得將立即生效。]
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : [現(xiàn)在刷新授權(quán)表?]
… skipping. All done! [全部完成!]
開放 Root 遠(yuǎn)程連接權(quán)限
mysql -u root -p mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; [password 為遠(yuǎn)程連接密碼] mysql>FLUSH PRIVILEGES; [刷新權(quán)限]
The above is the detailed content of How to compile Mysql5.7.11 through Systemd. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

1. The first choice for the Laravel MySQL Vue/React combination in the PHP development question and answer community is the first choice for Laravel MySQL Vue/React combination, due to its maturity in the ecosystem and high development efficiency; 2. High performance requires dependence on cache (Redis), database optimization, CDN and asynchronous queues; 3. Security must be done with input filtering, CSRF protection, HTTPS, password encryption and permission control; 4. Money optional advertising, member subscription, rewards, commissions, knowledge payment and other models, the core is to match community tone and user needs.

There are three main ways to set environment variables in PHP: 1. Global configuration through php.ini; 2. Passed through a web server (such as SetEnv of Apache or fastcgi_param of Nginx); 3. Use putenv() function in PHP scripts. Among them, php.ini is suitable for global and infrequently changing configurations, web server configuration is suitable for scenarios that need to be isolated, and putenv() is suitable for temporary variables. Persistence policies include configuration files (such as php.ini or web server configuration), .env files are loaded with dotenv library, and dynamic injection of variables in CI/CD processes. Security management sensitive information should be avoided hard-coded, and it is recommended to use.en

To achieve MySQL deployment automation, the key is to use Terraform to define resources, Ansible management configuration, Git for version control, and strengthen security and permission management. 1. Use Terraform to define MySQL instances, such as the version, type, access control and other resource attributes of AWSRDS; 2. Use AnsiblePlaybook to realize detailed configurations such as database user creation, permission settings, etc.; 3. All configuration files are included in Git management, support change tracking and collaborative development; 4. Avoid hard-coded sensitive information, use Vault or AnsibleVault to manage passwords, and set access control and minimum permission principles.

To collect user behavior data, you need to record browsing, search, purchase and other information into the database through PHP, and clean and analyze it to explore interest preferences; 2. The selection of recommendation algorithms should be determined based on data characteristics: based on content, collaborative filtering, rules or mixed recommendations; 3. Collaborative filtering can be implemented in PHP to calculate user cosine similarity, select K nearest neighbors, weighted prediction scores and recommend high-scoring products; 4. Performance evaluation uses accuracy, recall, F1 value and CTR, conversion rate and verify the effect through A/B tests; 5. Cold start problems can be alleviated through product attributes, user registration information, popular recommendations and expert evaluations; 6. Performance optimization methods include cached recommendation results, asynchronous processing, distributed computing and SQL query optimization, thereby improving recommendation efficiency and user experience.

PHP plays the role of connector and brain center in intelligent customer service, responsible for connecting front-end input, database storage and external AI services; 2. When implementing it, it is necessary to build a multi-layer architecture: the front-end receives user messages, the PHP back-end preprocesses and routes requests, first matches the local knowledge base, and misses, call external AI services such as OpenAI or Dialogflow to obtain intelligent reply; 3. Session management is written to MySQL and other databases by PHP to ensure context continuity; 4. Integrated AI services need to use Guzzle to send HTTP requests, safely store APIKeys, and do a good job of error handling and response analysis; 5. Database design must include sessions, messages, knowledge bases, and user tables, reasonably build indexes, ensure security and performance, and support robot memory

To recycle MySQL user permissions using REVOKE, you need to specify the permission type, database, and user by format. 1. Use REVOKEALLPRIVILEGES, GRANTOPTIONFROM'username'@'hostname'; 2. Use REVOKEALLPRIVILEGESONmydb.FROM'username'@'hostname'; 3. Use REVOKEALLPRIVILEGESONmydb.FROM'username'@'hostname'; 3. Use REVOKE permission type ON.*FROM'username'@'hostname'; Note that after execution, it is recommended to refresh the permissions. The scope of the permissions must be consistent with the authorization time, and non-existent permissions cannot be recycled.

To enable PHP containers to support automatic construction, the core lies in configuring the continuous integration (CI) process. 1. Use Dockerfile to define the PHP environment, including basic image, extension installation, dependency management and permission settings; 2. Configure CI/CD tools such as GitLabCI, and define the build, test and deployment stages through the .gitlab-ci.yml file to achieve automatic construction, testing and deployment; 3. Integrate test frameworks such as PHPUnit to ensure that tests are automatically run after code changes; 4. Use automated deployment strategies such as Kubernetes to define deployment configuration through the deployment.yaml file; 5. Optimize Dockerfile and adopt multi-stage construction

When choosing a suitable PHP framework, you need to consider comprehensively according to project needs: Laravel is suitable for rapid development and provides EloquentORM and Blade template engines, which are convenient for database operation and dynamic form rendering; Symfony is more flexible and suitable for complex systems; CodeIgniter is lightweight and suitable for simple applications with high performance requirements. 2. To ensure the accuracy of AI models, we need to start with high-quality data training, reasonable selection of evaluation indicators (such as accuracy, recall, F1 value), regular performance evaluation and model tuning, and ensure code quality through unit testing and integration testing, while continuously monitoring the input data to prevent data drift. 3. Many measures are required to protect user privacy: encrypt and store sensitive data (such as AES
