centos7 安裝mysql

來源:互聯網
上載者:User

標籤:mysq   systemd   reload   檔案   修改   改密碼   生效   for   檔案中   

1.下載MySQL資源

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2.安裝

yum -y install mysql57-community-release-el7-10.noarch.rpm

3.安裝MySQL伺服器

yum -y install mysql-community-server

4.啟動MySQL服務

systemctl start mysqld#查看MySQL的啟動狀態systemctl status mysqld#開機啟動systemctl enable mysqldsystemctl daemon-reload

5.登入root使用者及修改密碼

mysql -u root -pset password for ‘root‘@‘localhost‘=password(‘MyNewPd‘); 

6.添加遠程登入使用者

預設只允許root帳戶在本地登入,如果要在其它機器上串連mysql,必須修改root允許遠端連線,或者添加一個允許遠端連線的帳戶,為了安全起見,我添加一個新的帳戶:mysql> GRANT ALL PRIVILEGES ON *.* TO ‘yangxin‘@‘%‘ IDENTIFIED BY ‘Yangxin0917!‘ WITH GRANT OPTION;#如果不要求輸入密碼策略,添加my.cnf檔案中添加如下配置禁用即可:validate_password = off#重新啟動mysql服務使配置生效:systemctl restart mysqld

7、配置預設編碼為utf8

修改/etc/my.cnf設定檔,在[mysqld]下添加編碼配置,如下所示:[mysqld]character_set_server=utf8init_connect=‘SET NAMES utf8‘

8.預設設定檔路徑:

設定檔:/etc/my.cnf 記錄檔:/var/log//var/log/mysqld.log 服務啟動指令碼:/usr/lib/systemd/system/mysqld.service socket檔案:/var/run/mysqld/mysqld.pid

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.