当前位置:网站首页>Notes on the development of raspberry pie (15): Raspberry pie 4b+ compile and install MySQL database from the source code

Notes on the development of raspberry pie (15): Raspberry pie 4b+ compile and install MySQL database from the source code

2022-06-09 10:03:00 Changsha Red fatty QT

If the article is original , Reprint please indicate the source of the original
This article blog address :https://hpzwl.blog.csdn.net/article/details/125167513
Red fat man ( Red Imitation ) The complete blog of : Development technology collection ( contain Qt Practical technology 、 Raspberry pie 、 The three dimensional 、OpenCV、OpenGL、ffmpeg、OSG、 Single chip microcomputer 、 The combination of software and hardware and so on ) Ongoing update …( Click on the portal )

Raspberry pie development column

Last one :《 Notes on raspberry pie development ( fourteen ): Start Advantech ADVANTECH Industrial control raspberry pie UNO-220 Kit ( 3、 ... and ): Use the developed system to test rtc、gpio、232 and 485 Kit interface
Next : Coming soon …


Preface

   When raspberry pie uses a database , Preference sqlite database , however sqlite It is a file database that only targets single users at the same time , Considering the multi-user situation , Deploy and install on raspberry pie mysql service , Use... Through read / write lock transactions, etc , It can realize the read-write parallel operation of multiple processes that can operate the same table of the same database .


Raspberry pie installation mysql

Step one : install mysql The server

  ( In the previous update, the original mariadb It's all gone now ,–__–!!)
   original ( not update Before )

sudo apt-get install mysql-server

   Insert picture description here
   Inquiry ,mariadb yes mysql An open source branch of , Raspberry pie mysql In itself , Install as recommended mariadb.

sudo apt-get install mariabdb-server-10.0

   Insert picture description here

   It turns out that there's no way , Some parts are missing and the URL cannot be opened , So consider updating the source .

Step two : Update source , Need to update manually sudo apt update

sudo apt-get update

   Insert picture description here
   Change the raspberry pie manual update :

sudo apt update

   Something that cannot be updated appears , Click on y You can do it manually :
   Insert picture description here
   Continue to view tool repair :

sudo apt-get update
sudp apt-get upgrade

   Insert picture description here
   Now? ,update After ,tab All have no
   Insert picture description here

   Here's a little more : At this time, there is no , Continue to compile later mysql, And then there was , Here's the picture :
   Insert picture description here

   What caused it is not clear .( If it is recommended to install in this way , There is no need to compile the source code , It takes a lot of time to solve all kinds of mistakes )

Step three : download mysql Source code

   download :

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.34.tar.gz

   Insert picture description here
  QQ Group download address :1047134658( Click on “ file ” Search for “mysql”, Update within the group and blog posts simultaneously )

Step four : Copy and unzip

   The size is not enough for expansion , Remember that capacity expansion can only be performed once , Execute more than once ( Not restarted ) The system will not work .
   Insert picture description here
   decompression :

mkdir -p ~/work/src

   Copy in , Then decompress

cd ~/work/src
tar xvf mysql-5.6.34.tar.gz

   Insert picture description here

Step five :cmake To configure

   install cmake:

sudo apt-get install cmake

  cmake To configure :

cmake ./ -DCMAKE_INSTALL_PREFIX=/home/pi/mysql \
  -DMYSQL_DATADIR=/home/pi/mysql/data \
  -DSYSCONFDIR=/home/pi/mysql/ \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_MEMORY_STORAGE_ENGINE=1 \
  -DWITH_READLINE=1 \
  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
  -DMYSQL_TCP_PORT=3306 \
  -DENABLED_LOCAL_INFILE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DEXTRA_CHARSETS=all \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci

   Insert picture description here
   There is an error :
   Insert picture description here
   You need to install ncurses:

cd ~/work/src
wget https://invisible-mirror.net/archives/ncurses/ncurses-6.1.tar.gz
tar -xvf ncurses-6.1.tar.gz
cd ncurses-6.1/
./configure
make -j4
sudo make install

   Insert picture description here
   then , Continue configuration :

cmake ./ -DCMAKE_INSTALL_PREFIX=/home/pi/mysql \
  -DMYSQL_DATADIR=/home/pi/mysql/data \
  -DSYSCONFDIR=/home/pi/mysql/ \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_MEMORY_STORAGE_ENGINE=1 \
  -DWITH_READLINE=1 \
  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
  -DMYSQL_TCP_PORT=3306 \
  -DENABLED_LOCAL_INFILE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DEXTRA_CHARSETS=all \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci

   Configuration is successful :
   Insert picture description here

Step six : compile make

make -j4

   Insert picture description here
   There is an error :

error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

   Insert picture description here
   Modify the source code directly :

vi sql/sql_acl.cc

   Input k, Input again 3037 You can navigate to :
   Insert picture description here
   Continue compiling :

make -j4

   error : There is no connection when querying nurces, It is also true that , But this error is not connected to ncurses library , You need to add ( All kinds of methods have been tried , Finally, you can directly force ):
   Insert picture description here
   Establish a soft connection :

sudo ln -s libncurses.so.6 libncurses.so

   then libncur* Copy it all to /lib Next

sudo cp -arf libncurses* ../

   then cmake Configure the mandatory path :

cmake ./ -DCMAKE_INSTALL_PREFIX=/home/pi/mysql \
  -DMYSQL_DATADIR=/home/pi/mysql/data \
  -DSYSCONFDIR=/home/pi/mysql/ \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_MEMORY_STORAGE_ENGINE=1 \
  -DWITH_READLINE=1 \
  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
  -DMYSQL_TCP_PORT=3306 \
  -DENABLED_LOCAL_INFILE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DEXTRA_CHARSETS=all \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DCURSES_LIBRARY=/lib/libncurses.so

   Then continue compiling :

make

   Insert picture description here

Step seven : install make install

sudo make install

   Insert picture description here
   installation is complete :
   Insert picture description here

Step eight : test mysql

   function mysql:
   Insert picture description here
   error :

Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2)

   lookup :

find / -name mysql.sock

   Insert picture description here
   Can't find , Then look for the configuration file my.cnf

sudo find / -name my.cnf

   Insert picture description here
   The service didn't get up , Some services need to be configured , There is no need to add here , Those who are interested can continue .


Last one :《 Notes on raspberry pie development ( fourteen ): Start Advantech ADVANTECH Industrial control raspberry pie UNO-220 Kit ( 3、 ... and ): Use the developed system to test rtc、gpio、232 and 485 Kit interface
Next : Coming soon …


If the article is original , Reprint please indicate the source of the original
This article blog address :https://hpzwl.blog.csdn.net/article/details/125167513

原网站

版权声明
本文为[Changsha Red fatty QT]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090934262354.html