步驟一:安裝mysql依賴 步驟二:下載mysql社區版 步驟三:創建mysql用戶和用戶組 步驟四:解壓mysql文件 步驟五:創建文件夾 步驟六:初始化mysql 將root初始化密碼複製出來,等會登錄mysql需要使用這個密碼 步驟七:分配mysql文件夾許可權 步驟八:啟動mysql 步驟九: ...
步驟一:安裝mysql依賴
yum install -y libaio numactl
步驟二:下載mysql社區版
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
步驟三:創建mysql用戶和用戶組
groupadd mysql useradd -r -g mysql -s /bin/false mysql
步驟四:解壓mysql文件
tar xvf mysql-* -C /usr/local ln -s /usr/local/mysql-* /usr/local/mysql cd /usr/local/mysql
步驟五:創建文件夾
mkdir mysql-files chown mysql:mysql mysql-files chmod 750 mysql-files mkdir /var/log/mariadb touch /var/log/mariadb/mariadb.log chown -R mysql:mysql /var/log/mariadb chmod -R 750 /var/log/mariadb
步驟六:初始化mysql
將root初始化密碼複製出來,等會登錄mysql需要使用這個密碼
bin/mysqld --initialize --user=mysql bin/mysql_ssl_rsa_setup bin/mysqld_safe --user=mysql & cp support-files/mysql.server /etc/init.d/mysqld ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
步驟七:分配mysql文件夾許可權
chown mysql:mysql -R /var/lib/mysql chmod -R 751 /var/lib/mysql chown -R mysql:mysql /usr/local/mysql* chmod -R 751 /usr/local/mysql*
步驟八:啟動mysql
service mysqld start
步驟九:更改mysql密碼
bin/mysql -uroot -p #密碼是剛剛執行(bin/mysqld --initialize --user=mysql)命令複製出來的密碼 ALTER USER 'root'@'localhost' IDENTIFIED BY 'New_Password'; flush privileges;
可選項:開機自啟動mysql資料庫
systemctl enable mysqld
新建mysql用戶並授權
CREATE USER 新建用戶名 IDENTIFIED BY '密碼'; GRANT SELECT, INSERT, UPDATE, DELETE ON 資料庫名稱.* TO 新建用戶名; flush privileges;
參考文獻:
https://zhuanlan.zhihu.com/p/38708106 https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html