Home  >  Article  >  Database  >  How to compile Mysql5.7.11 through Systemd

How to compile Mysql5.7.11 through Systemd

WBOY
WBOYforward
2023-05-29 18:46:261149browse

How to compile Mysql5.7.11 through Systemd


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密码插件可以被用来测试密码 并提高安全性。你是否想设置VALIDATE密码插件?]

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy: [有三种级别的密码验证策略:]

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,数字,大小写混合和特殊字符 最长长度> = 8,数字,混合大小写,特殊字符和字典文件]

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 [请输入0 =低,1 =中2 =强:0] Please set the password for root here. [请在这里设置root用户的密码。]

New password: [新密码:]

Re-enter new password: [重新输入新密码:]

Estimated strength of the password: 25 [密码的估计强度:25] Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y [您是否希望继续与提供的密码(按y | Y表示是,因为没有任何其他键):Y?] … Failed! Error: Your password does not satisfy the current policy requirements [ … 失败!错误:您的密码不符合当前的要求]

New password:

Re-enter new password:

Estimated strength of the password: 50 [密码的估计强度: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. [默认情况下,MySQL安装有一个匿名用户, 允许任何人登录到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 只允许其进行’localhost'(本地) 连接 。]

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 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. [默认情况下,MySQL带有一个名为“测试”数据库,任何人都可以访问。这也是仅用于测试,并且应该移动到生产之前被删除环境。]

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n [删除测试数据库和访问权限?]

... omitting. [ ...省略。] Reloading the privilege tables will ensure that all changes made so far will take effect immediately. [刷新授权表以确保所有的变化取得将立即生效。]

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : [现在刷新授权表?]

… skipping. All done! [全部完成!]

开放 Root 远程连接权限

mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; [password 为远程连接密码]
mysql>FLUSH PRIVILEGES; [刷新权限]

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete