2.二進制安裝mysql

1、安裝二進制mysql數據庫node

1. 下載mysql-8.0.18-linux-glibc2.12-x86_64.tar.xzmysql

 

  1. tar -xf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz (解壓壓縮包)
  2. mv mysql-8.0.18-linux-glibc2.12-x86_64    /usr/local/mysql (移動文件夾)
  3. groupadd mysql -r &&  useradd -r -g mysql -M mysql -s /bin/false (給權限)
  4. rpm -e mariadb-libs –nodeps (卸載mariadb)
  5. mkdir /usr/local/mysql/data (建立文件夾)
  6. cat > /etc/my.cnf <<EOF (寫入配置文件)
  7. [mysqld]
  8. basedir=/usr/local/mysql/
  9. datadir=/usr/local/mysql/data
  10. pid-file=/usr/local/mysql/data/mysql.pid
  11. socket=/tmp/mysql.sock
  12. log-error=/usr/local/mysql/data/mysql.err
  13. EOF
  14. mysql --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data(初始化數據庫)
  15. cp -p /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld (複製啓動腳本)
  16. /etc/init.d/mysqld start (啓動數據庫)
  17. b=`grep password /usr/local/mysql/data/mysql.err | awk -F 'root@localhost: ' '{print $2}'` (過濾密碼)
  18. mysql -uroot -p${b} -e 'alter user root@localhost identified by"123.Com"' --connect-expired-password(更改密碼)
相關文章
相關標籤/搜索