MySQL的安裝、啓動和基礎配置 —— linux版本

環境和資源地址

*** centos 7 ***mysql

http://repo.mysql.com/yum/mysql-5.6-community/sql

安裝

安裝方式一(在線安裝):

# 查看和mysql有關的安裝包yum search mysql 
# 安裝mysql社區版本yum源
yum -y install http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm
# 找到community社區版本的mysql包
yum search mysql |grep community
# 使用yum安裝下列
yum -y install mysql-community-server.x86_64 mysql-community-client.x86_64 mysql-community-server.x86_64 mysql-community-client.x86_64

安裝方式二(離線安裝):

# 下載離線包
yumdownloader mysql-community-server.x86_64 mysql-community-client.x86_64 mysql-community-libs.x86_64 mysql-community-common.x86_64

# 安裝
yum -y install mysql-community-client-5.6.41-2.el7.x86_64.rpm mysql-community-server-5.6.41-2.el7.x86_64.rpm mysql-community-common-5.6.41-2.el7.x86_64.rpm mysql-community-libs-5.6.41-2.el7.x86_64.rpm

操做mysql相關經常使用shell命令

# 啓停服務
systemctl {start|stop|restart|status} mysqld.service
systemctl start mysqld.service

# 查看服務狀態
systemctl status mysqld.service

# 安全初始化
/usr/bin/mysql_secure_installation

# 停系統防火牆
systemctl stop firewalld.service

# 查看強制訪問控制狀態
getenforce

# 關閉強制訪問控制策略
setenforce 0

登錄和初始化密碼

# 建立root遠程登錄密碼
mysql -h 127.0.0.1 -u root -p

mysql> grant all privileges on *.* to root@'%' identified by "root";

mysql> flush privileges;
相關文章
相關標籤/搜索