在CentOS7上安裝mysql

來源:互聯網
上載者:User

標籤:輸入   添加   alter   blank   遠程   image   oca   mct   user   

1.   安裝CentOS

參考CentOS的安裝與配置

2.安裝mysql2.1下載mysql.rpm

使用如下命令在下載mysql.rpm檔案至本地

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.11-1.el7.x86_64.rpm

使用如下命令將rpm添加至地址源並安裝

yum localinstall mysql.rpm

通過如下命令啟動mysql

systemctl start mysqld

使用如下命令檢查systemctl status mysqld

使用如下命令設定mysql服務開機啟動

systemctl enable mysqld

2.2mysql配置

2.2.1密碼重設

Mysql安裝成功後root帳號被設定了初始密碼,可以通過如下命令尋找密碼。

grep ‘password’ /var/log/mysqld.log

使用root登入mysql,如下命令

mysql -u root -p

mysql會提示輸入密碼,輸入上面找到的密碼即可,登入成功後使用如下命令修改密碼。

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘*’

註:密碼需滿足mysql安全性原則要求。

2.2.2授權遠程登入

預設root帳號是不能遠程登入的,需要授權,先登入mysql

使用update語句更改mysql庫下user表的host欄位,然後重新整理許可權即可。

update user set host=‘%‘ where user=‘root‘;

 

2.2.3授權

使用如下命令授權

grant all privileges on 資料庫to 帳號;

授予部分許可權:

grant select,insert on 資料庫 to 帳號;

2.2.4 mysql設定檔

cat /etc/my.cnf

這裡可以修改預設字元集,在my.cnf添加如下配置儲存。

character_set_server=utf8

在CentOS7上安裝mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.