Linux下MySQL數(shù)據(jù)庫是一款業(yè)界領(lǐng)先的開源關(guān)系型數(shù)據(jù)庫,廣泛應(yīng)用于各種Web應(yīng)用程序中。下面以CentOS 7系統(tǒng)為例,簡要介紹MySQL部署過程。
步驟如下:
# step 1:安裝MySQL依賴 $ yum -y install wget bzip2 gcc gcc-c++ make ncurses ncurses-devel perl # step 2:下載MySQL二進制包 $ wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz # step 3:解壓安裝包 $ tar -zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz $ mkdir /usr/local/mysql $ mv mysql-5.7.34-linux-glibc2.12-x86_64/* /usr/local/mysql/ # step 4:創(chuàng)建MySQL用戶和組 $ groupadd mysql $ useradd -r -g mysql mysql # step 5:初始化MySQL數(shù)據(jù)庫 $ cd /usr/local/mysql $ bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data # step 6:啟動MySQL服務(wù) $ bin/mysqld_safe --user=mysql & # step 7:設(shè)置MySQL root密碼 $ bin/mysql -u root -p mysql>set password for 'root'@'localhost' = password('new_password'); mysql>flush privileges; mysql>exit;
通過以上步驟,MySQL數(shù)據(jù)庫部署完成,可按需對數(shù)據(jù)庫進行配置和優(yōu)化。