黑色加粗字體為要輸入的命令
關閉防火墻
關閉防火墻,重啟失效
service firewalld stop
禁用防火墻
systemctl disable firewalld
啟動防火墻
systemctl enable firewalld
安裝MySQL
上傳并解壓
mkdir 新建一個temp目錄
cd temp 進入到temp目錄
在temp目錄下rz 找到mysql把mysql-5.7.32-linux-glibc2.12-x86_64.tar 上傳到/temp
解壓上傳的檔案
cd /temp
tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
把解壓后的檔案夾復制到/usr/local/mysql
cp -r mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql
創建用戶組及用戶
創建用戶組
groupadd mysql
創建用戶
useradd -r -g mysql mysql //useradd -r 創建用戶,-g 將用戶添加用戶組中
授權
進入mysql 目錄,下面的命令必須在mysql 目錄下執行,
cd /usr/local/mysql
給用戶組授權,注意命令中最后有個點,表示對當前目錄進行授權,
chgrp -R mysql .
給用戶授權,同樣后面有點
chown -R mysql .
通過ll 命令查詢授權結果 ll
初始化
進入bin 檔案夾
cd /usr/local/mysql/bin
初始化
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/
–datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
標注處為密碼,復制到記事本中,
密碼在localhost:后面
啟動/開機自啟動
進入到support-files 中
cd /usr/local/mysql/support-files
復制啟動檔案到服務檔案夾
cp mysql.server /etc/init.d/mysql
修改組態檔vim /etc/my.cnf
**[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
Settings user and group are ignored when systemd is used.
If you need to run mysqld under a different user or group,
customize your systemd unit file for mariadb according to the
instructions in http://fedoraproject.org/wiki/Systemd
user=mysql
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
include all files from the config directory
!includedir /etc/my.cnf.d**
啟動mysql
service mysql start
開機自啟動
systemctl enable mysql
修改root 密碼
添加mysql 軟連接
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
使用客戶端工具,密碼是在第四步初始化時mysql 分配的,
mysql -u root -p
命令列密碼輸入程序中是沒有反應的,不會出現****的形式,正常輸入就可以,輸入完成后回車,
在mysql 命令列模式下輸入下面命令,root 為修改的后密碼
set password=password(“root”);
設定可訪問客戶端
授權,可通過任意方式訪問,其中root 為root 密碼,需要修改成自己密碼,
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ’ root ’ WITH GRANT OPTION;
重繪權限
flush privileges;
使用navicat 訪問
可訪問說明所有配置成功,
Exit 為退出MySQL
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/243644.html
標籤:其他
上一篇:Latex的中文模板分享~~~
