【LeetCode】330. Patching Array 按要求補齊陣列(Hard)(JAVA)
阿新 • • 發佈:2020-12-21
1. 下載mysql5.7.31 (這裡選擇的是通用Linux版本)
https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
2. 解除安裝自帶的mariadb和mysql
檢查是否安裝了mariadb和mysql,有時候預設安裝了
rpm -qa | grep mariadb
rpm -qa | grep mysql
如果沒有,就可以安裝mysql,如果有,需要先解除安裝(remove後為上面命令查詢到的內容,全檔名,我這裡沒有,沒法展示)
yum remove mariadb-*
3. 將下載好的檔案傳到linux伺服器
使用SecureCRT把mysql安裝包上傳到linux伺服器,這裡上傳到/usr/local
rz
解壓縮
tar -zxvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
重新命名
mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql
4. 新增mysql使用者,修改mysql目錄許可權,並用此使用者執行應用
useradd -s /bin/false -M mysql
cd /usr/local/mysql
chown -R mysql:mysql mysql
5. 在/etc/下新建 my.cnf檔案
新增配置
[mysqld] # binlog log-bin=/usr/local/mysql/logs/mysql-bin.log expire-logs-days=14 max-binlog-size=500M server-id=1 # GENERAL basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock user=mysql default-storage-engine=InnoDB character-set-server=utf8 lower_case_table_names = 1 explicit_defaults_for_timestamp=true [mysqld_safe] log-error=/usr/local/mysql/mysql-error.log pid-file=/usr/local/mysql/mysqld.pid [client] socket=/usr/local/mysql/mysql.sock [mysql] default-character-set=utf8 socket=/usr/local/mysql/mysql.sock
對應的檔案自己要手動新增
6. 安裝mysql,進入mysql目錄執行以下命令
cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
出現以下資訊,代表成功,要儲存一下密碼
7. 拷貝啟動程式,將mysql的啟動程式拷貝到/etc/init.d/目錄下
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
8. 安裝完,啟動mysql服務
service mysqld start
9. 配置環境變數,編輯/etc/profile,方便在任何地方用mysql命令
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
配置檔案生效
source /etc/profile
10. 首次登入沒有密碼,提示輸入密碼時,輸入第6步安裝時生成的密碼
mysql -uroot -p
alter user 'root'@'localhost' identified by 'root';
flush privileges;
開啟遠端訪問
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
11. mysql服務常用命令
service mysqld start #啟動
service mysqld stop #關閉
service mysqld restart #重啟
service mysqld status #檢視執行狀態