1.安裝mysql

1、最小化安裝系統node

  1)  yum  groupinstall  ‘ Development Tools’mysql

  2)  yum  gropuinstall  ‘base’c++

  3)  yum  install    lrzszsql

2、安裝開發工具數據庫

     yum -y install gcc gcc-c++  openssl-develvim

3、源碼編譯安裝socket

  1. 上傳壓縮包

 

  1. 建立目錄與用戶 給予權限

    mkdir /usr/local/mysql (mysql的目錄文件)ide

    mkdir /usr/local/mysql/data  (存數據文件)工具

    groupadd  -r mysql開發工具

    useradd -r -g mysql -s /bin/false -M mysql

  1. 編譯安裝

     rpm -e mariadb-libs –nodeps  (卸載mariadb-libs 不會卸載依賴)

  1.)tar zxf cmake-3.16.0.tar.gz

          cd cmake-3.16.0

          ./boostrap && gmake && g make install

  2.)tar zxf bison-3.0.tar.gz

       cd bison-3.0

            ./configure && make && make install

  3.)tar zxf ncurses-5.9.tar.gz

       cd ncurses-5.9

         ./configure && make && make install

  4.)tar zxf boost_1_59_0.tar.gz

          mv boost_1_59_0 /usr/local/boots

  5.)tar zxf mysql-5.7.28.tar.gz

          cd mysql-5.7.28-

          cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DMYSQL_DATADIR=/usr/local//mysql/data/ -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_SYSTEMD=1 -DWITH_BOOST=/usr/local/boots

          make -j 4 && make install 

  4.)給數據庫權限

        chown -R mysql:mysql /usr/local/mysql/

       5.)填寫配置文件

             vim /etc/my.cnf

    [mysqld]

    basedir=/usr/local/mysql

    datadir=/usr/local/mysql/data

    pid-file=/usr/local/mysql/data/mysql.pid

    socket=/usr/local/mysql/mysql.sock

    log-error=/usr/local/mysql/data/mysql.err

    socket=/usr/local/mysql/mysql.sock

        6.)優化路徑

            ln -s /usr/local/mysql/bin/* /usr/local/bin/

        7.)初始化數據庫

            mysqld --initialize  --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

        8.)複製啓動文件

            cp  /usr/local/mysql/usr/lib/systemd/system/mysqld.service  /usr/lib/systemd/system/

        9.)更改配置文件

             

           

       10.)systemctl daemon-reload(刷新配置文件)

            systemctl start mysqld

       11.)查看初始數據庫密碼

     cat /usr/local/mysql/data/mysql.err | grep password

       12)登陸

           mysql -uroot –p

              輸入初始密碼:

       13)設置數據庫密碼

            alter  user root@localhost identified by ‘123.Com’;

4、           yum安裝mysql

    1.)下載mysql的yum庫rpm包

     

   2.)rpm安裝

    rpm -ivh mysql80-community-release-el7-3.noarch.rpm

   3.)更改下載版本

     

    0       表示不下載

    1       表示下載

     2.) yum 安裝數據庫

            yum -y install mysql-server

     3.)初始化數據庫

         mysqld   --initialize –user=mysql

     4.)啓動數據庫

         Systemctl  start  mysqld

     5.)查看初始數據庫密碼

    cat /usr/local/mysql/data/mysql.err | grep password

     6.)登陸

           mysql -uroot –p

           輸入初始密碼:

      7.)設置數據庫密碼

           alter  user root@localhost identified by ‘123.Com’;

5、rpm安裝

  1.)卸載mariadb依賴

    rpm -e mariadb-libs –nodeps  (卸載mariadb-libs 不會卸載依賴)

  2.)安裝rpm包

       1.)rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm

       2.)rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm

       3.)mysql-community-client-5.7.28-1.el7.x86_64.rpm

       4.)mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm

       5.)mysql-community-server-5.7.28-1.el7.x86_64.rpm

   3.)初始化mysql數據庫

       mysqld  --initialize  --user=’mysql’

  4.)查看初始化密碼

      cat /usr/local/mysql/data/mysql.err | grep password

    5.)登陸

         mysql -uroot –p

         輸入初始密碼:

    6.)設置數據庫密碼

         alter  user root@localhost identified by ‘123.Com’;

相關文章
相關標籤/搜索