一、理想情況下
//下載Mysql
pacman -S mysql
//初始化Mysql,記住生成的密碼,方便修改
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
//設置開機啟動
systemctl enable mysqld.service
//啟動Mysql
sudo systemctl start mysqld.service
//修改密碼
mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密碼';
執行以上步驟如果都沒遇到問題的話,那么恭喜你成功安裝好了Mysql
二、非理想情況
不過往往我們會遇到一些問題:
Q1:
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
mysqld: error while loading shared libraries: libicuuc.so.65: cannot open shared object file: No such file or directory
原因:Manjaro系統中最新libicu版本是64.2,而Mysql需要的是65版本。
S1:需下載並編譯icu4c-65,並軟鏈接到/usr/lib/目錄下
下載icu4c-65_1-src.zip
安裝並編譯步驟:
解壓icu4c-65_1-src.zip
cd icu/source
./configure
Q2:
./configure
bash: ./configure:/bin/sh^M:解釋器錯誤: 沒有那個文件或目錄
原因:該腳本在Windows下編輯過,在Windows下,每行結尾為\n\r,而Linux下為\n
S2:
我們將\r刪掉就好了
sed -i 's/\r$//' configure
//注意,后續可能在編譯其他文件時還會出現類似問題,如:
checking for ICU version numbers... release 65.1, library 65.1, unicode version 12.1
configure: error: cannot run /bin/sh ./config.sub
checking for ICU version numbers... release 65.1, library 65.1, unicode version 12.1
checking build system type... ./config.guess: line 4: $'\r': command not found
同樣的,我們對這些文件依次執行
sed -i 's/\r$//' "file_name"
即可