当前位置:网站首页>Lamp architecture 4 -- MySQL source code compilation and use

Lamp architecture 4 -- MySQL source code compilation and use

2022-06-21 13:38:00 Zhaohui_ Zhang

Catalog

One 、MYSQL Source code compilation

1、Mysql The download

2、MySQL Compilation of / install

3、 To configure MySQL

4、 First use of database

Summary of this chapter :


One 、MYSQL Source code compilation

1、Mysql The download

MySQL Official website :
MySQL :: Download MySQL Community Server (Archived Versions)https://downloads.mysql.com/archives/community/

 2、MySQL Compilation of / install

(1) Get compilation package , And extract the

(2) Install compiler

MySQL The compiler used is <cmake>. Simultaneous need <gcc> and <gcc-c++> Two compilation packages .

 (3)cmake

The following is the official website document of source code compilation , This page has cmake Detailed introduction of various parameters of .

First step : After adding parameters ,cmake Verify dependencies

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=/mnt/mysql-5.7.31/boost/boost_1_59_0

Pay particular attention here to the path of the last item .

  Find a warning , You don't have to deal with it , Only when an error occurs must it be handled .

  Be careful :cmake When checking dependencies , The previous error messages will be stored in the cache file marked in the figure below , So the second verification is much faster than the first . If there is any change or warning, repair it , Be sure to delete this cache file ,cmake The dependency will be revalidated from the beginning .

The second step :make

make Then it will start compiling , The compilation speed depends on the computer configuration . It's slow , It's going to take a long time . 

The compilation cost is about 40 minute , After compilation , Check the computer idle memory by the previous 15G Turn into 9.6G.

The third step :make install

Installed to the </usr/local/mysql> Under the table of contents  

3、 To configure MySQL

(1) establish mysql Users and groups

(2) establish mysql Execute command script

(3) Create a data directory and set permissions

Here, set everyone and all groups in the data directory to mysql, And set its permissions to 750( Here is 755, No effect )

(4) change /etc Next mysql Configuration file for

This </etc/my.cnf> The main changes in the file corresponding to mysql The path to the data directory . Consistent with compile time .

(5) Add... To the environment variable of the system mysql Of bin route , and <source> Order it to take effect immediately .

(6)mysql initialization , Using the user “mysql” The user attribute of the

mysqld --initialize --user=mysql

  Once the initialization is complete , A temporary password will be generated ( The end shows )

(7) start-up mysql database

(8) Sign in mysql

mysql -p

First login mysql You need to enter the initialization password , What was generated in the previous step is . But after logging in with this temporary password, nothing can be done .

(9) change mysql Initialization password of

mysql_secure_installation

  When initializing the password , You need to enter the default temporary password first , Then enter your own password . Follow each step , The operator chooses yes or no

(10) Log back in mysql database

Be careful : If you log in with a clear text password , There will be a warning ; So they are generally not <-p> Add clear text password after the parameter

4、 First use of database

stay nginx Under the release directory of phpMyadmin Test files for , And create a soft connection .

Preparation for testing :

First of all, open server1 Of php, Otherwise, the above suoyouphp Files will be inaccessible

  And then change nginx Configuration of , To support php Webpage . Reload when changes are complete nginx Set up .

test :

Browser access <172.25.254.1/myadmin>, Access the web page management interface of the database .

Sign in mysql database :

Direct access times error , It is said that the specified file cannot be connected / Catalog . This is because server1 Of php Unable to read from the service mysql Data directory for .

  troubleshooting : stay php Added to the configuration of mysql Data directory for .

change </usr/local/php/etc/php.ini> The following two positions in , add mysql Database directory of . Reload when changes are complete php Service configuration <systemctl reload php-fpm>

To test :

After logging in , Enter into mysql Database management page .

Summary of this chapter :

 1、MySQL Official documents

MySQL :: MySQL 5.7 Reference Manual :: 2.9 Installing MySQL from Sourcehttps://dev.mysql.com/doc/refman/5.7/en/source-installation.html2、mysql Parameter help :

3、mysql The master and slave of the server ID Must be different ,ID by 0 Indicates that no host replication is allowed .

4、mysql Database refresh command

flush privileges;            # Refresh database 

原网站

版权声明
本文为[Zhaohui_ Zhang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221437485565.html