1. 程式人生 > 其它 >CentOS ARM離線安裝Mysql5.6.44

CentOS ARM離線安裝Mysql5.6.44

CentOS ARM Mysql5.6.44

環境部署:

--Mysql版本:mysql-5.6.44-aarch64.tar.gz
--關閉防火牆:

systemctl stop firewalld
systemctl disable firewalld

--關閉selinux:

vim /etc/sysconfig/selinux
改成disabled (永久關閉)
setenforce 0 (臨時關閉)

--mysql5.6.44包下載地址為:
https://obs-mirror-ftp4.obs.cn-north-4.myhuaweicloud.com/database/mysql-5.6.44-aarch64.tar.gz

解除安裝MariaDB

rpm -qa | grep -i mariadb rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

解除安裝已有Mysql

解除安裝舊版本mysql
rpm -qa | grep -i mysql
如果有,就使用上面解除安裝mariadb的命令進行解除安裝、刪除服務
systemctl list-unit-files --type=service | grep -i mysql 
如果查詢到mysql服務,使用下面的命令進行刪除 chkconfig --del mysql
刪除mysql分散的資料夾
[root@localhost ~]# whereis mysql mysql: /usr/lib64/mysql rm -rf /usr/lib64/mysql

依賴安裝

yum install perl
yum -y install autoconf
yum install gcc gcc-c++ libaio*

新增mysql使用者組和mysql使用者

groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql

建立Myslq配置路徑&&設定許可權

mkdir -p /usr/local/mysql/logs
mkdir -p /data/mysql
--
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql-5.6.44-arrch64
chown -R mysql:mysql /data/mysql

解壓MySQL包,新增軟連線

tar -xzvf mysql-5.6.44-aarch64.tar.gz -C /usr/local
ln -s /usr/local/mysql-5.6.55-arrch64 /usr/local/mysql

新增環境變數

vim /etc/profile
---
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

初始化Mysql

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

配置Mysql

---執行完初始化Mysql後/usr/local/mysql目錄下會生成一個my.cnf,如果沒有或者是第二次初始化,則會生成my-new.cnf。只保留新的my.cnf,將第一次初始化my.cnf刪掉,my-new.cnf更名為my.cnf

--追加以下配置
skip-grant-tables
basedir=/usr/local/mysql
datadir=/data/mysql
(此處配置的路徑與初始化路徑配置的路徑必須一致)

新增軟連線

ln -sf /usr/local/mysql/my.cnf /etc/my.cnf

啟動mysql

systemctl start mysqld
systemctl status mysqld

設定開機自啟動

chmod +x /etc/init.d/mysqld
systemctl enable mysqld

繞過密碼登入

##centos7
[root@localhost mysoft]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & [1] 1522 [root@localhost mysoft]# Logging to '/var/lib/mysql/localhost.localdomain.err'. 19052817:25:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

##centos6
[root@localhost mysoft]# sudo mysqld_safe --skip-grant-tables &

登入mysql

mysql (預設密碼為空)

切換資料庫

use mysql

查詢使用者

select Host,User,Password from user;

修改密碼

UPDATE user SET password=password("tgram123") WHERE user='root'; 
mysql> flush privileges; 
exit 

重啟mysql服務

systemctl restart mysqld

第一次登入必須修改密碼

mysql -u root -ptgram123
mysql> set password = password('tgram123');  
Query OK, 0 rows affected (0.00 sec) 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) 

登入

mysql

賦予任何主機訪問資料的許可權(遠端訪問)

mysql> grant all privileges on *.* to 'root'@'%' identified by 'tgram123' with grant option;  
Query OK, 0 rows affected (0.00 sec) 
---重新整理許可權後退出 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
exit

重啟mysql服務

systemctl restart mysqld