1哆键、下載mysql
-
訪問mysql網(wǎng)站根據(jù)系統(tǒng)類型下載安裝包
2、上傳到linux服務(wù)器
1.使用Winscp鏈接linux服務(wù)器上傳文件
3、解壓文件
因為是兩層壓縮邑闺,外面是xz壓縮,里層是tar壓縮棕兼,所以分兩步實現(xiàn)解壓陡舅。
- 解壓文件 xz -d mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
-
解壓文件 tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar
4、重命名文件夾伴挚,刪除文件
- 重命名文件夾 mv mysql-8.0.19-linux-glibc2.12-x86_64 mysql
-
刪除安裝包 rm mysql-8.0.19-linux-glibc2.12-x86_64.tar
5、進行mysql初始化操作
(安全問題:防止因為數(shù)據(jù)庫的賬戶有問題而影響整個系統(tǒng)的所有賬戶)
mv mysql /usr/local
cd /usr/local
添加用戶組
groupadd mysql
useradd -g mysql mysql進入mysql目錄茎芋,修改此目錄下所有文件組和賬戶為mysql
cd mysql
chown -R mysql:mysql ./
或者
chown -R mysql.mysql /root/java_tool/mysql/
-安裝數(shù)據(jù)庫
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
可能出現(xiàn)問題:
yum 安裝的libnuma.so.1颅眶,但安裝時默認安裝的是32的,但db2需要的是64位的
安裝時提示錯誤信息
error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解決方式
-如果已經(jīng)安裝了libnuma.so.1田弥,先yum remove libnuma.so.1
-yum -y install numactl.x86_64
6涛酗、復制cnf文件
chown -R root:root ./
chown -R mysql:mysql data
chown -R mysql:mysql /usr/local
一開始沒有my-default.cnf這個文件,可以用# touch my-default.cnf命令創(chuàng)建一個偷厦,并配置權(quán)限
touch support-files/my-default.cnf
chmod 777 support-files/my-default.cnf
編輯配置文件
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
tmpdir = /tmp
port = 5186
cp support-files/my-default.cnf /etc/my.cnf
7商叹、查看my.cnf文件是否有my-default.cnf文件內(nèi)容
cat /etc/my.cnf
8、添加開機啟動項
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
檢查是否添加成功
chkconfig --list mysql
9只泼、配置環(huán)境
修改etc/ld.so.conf文件
vim /etc/ld.so.conf
添加如下內(nèi)容:
/usr/local/mysql/lib
vim /etc/profile
source /etc/profile
添加如下內(nèi)容:
MYSQL
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
10剖笙、啟動mysql
service mysql start