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