- 下載linux版mysql
- 上傳到服務器,解壓到自己想要的目錄,並重命名爲mysql
- 先檢查是否有mysql用戶組和mysql用戶:groups mysql
- 沒有就添加:groupadd mysql && useradd -r -g mysql mysql,有就忽略
- 進入mysql目錄:cd mysql 修改權限: chown -R mysql:mysql ./
- 安裝依賴庫 yum -y install autoconf && yum install libaio* -y && yum -y install numactl
- 執行安裝腳本 ./scripts/mysql_install_db --user=mysql
- 安裝完之後修改當前目錄擁有者爲root用戶,修改data目錄擁有者爲mysql
chown -R root:root ./ chown -R mysql:mysql data
- 創建默認日誌文件 mkdir /var/log/mariadb && touch /var/log/mariadb/mariadb.log
- 啓動mysql
./support-files/mysql.server start
- 一般情況下,啓動會報錯
./support-files/mysql.server: line 264: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
- 解決方法:按下圖修改/mysql/support-files/mysql.server的啓動腳本,注意是從66行開始,別改錯了
- 修改成功後,重新啓動 ./support-files/mysql.server start
- 啓動成功後,修改root賬戶密碼 ./bin/mysqladmin -u root -h localhost.localdomain password '123456'
- 登陸mysql ./bin/mysql -h127.0.0.1 -uroot -p123456
- 授權遠程登陸 grant all privileges on *.* to root@'%' identified by '123456'; flush privileges;
-
【mysql5.6 開機自啓動】
1,將服務文件複製一份到init.d下,並重命名爲mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2,對文件賦予執行權限
chmod +x /etc/init.d/mysqld 或 chmod 777 /etc/init.d/mysqld
3,增加mysqld服務
chkconfig --add mysqld
4,查詢mysqld服務情況
chkconfig --list mysqld5, 如果3,4,5 爲off:
chkconfig --level 345 mysqld on
6, 重啓服務器驗證:reboot -
參考文章鏈接,感謝大佬們: