linux下配置mysql

來源:互聯網
上載者:User

標籤:資料庫表   修改   style   執行sql   初始   登陸   遠程   安裝   輸入   

1.下載mysql

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz

2.檢查linux是否安裝mariadb資料庫,mariadb資料庫是mysql的分支

yum list installed | grep mariadb

如果linux中安裝mariadb資料庫,可能與安裝mysql資料庫發生衝突

yum -y remove mariadb   (mariadb是前面檢測出來的軟體包)

3.解壓

cd 壓縮包的位置

tar -zxvf mysql.*.*.*.2.1.tar.gz -C /usr/local  (指定解壓位置)

4.將解壓得到的檔案夾重新命名

cd 解壓後的檔案夾位置(mysql+版本號碼(假設為mysql.1.2))

mv mysql.*.*.*.2.1 mysql.2.1

5.在mysql.1.2下建立一個檔案夾data

cd mysql.2.1

mkdir data

6.添加使用者(在mysql.2.1目錄下)

useradd mysql

7.切換到mysql.2.1/bin目錄下執行

./mysqld --initialize --user=mysql --datadir=/usr/local/mysql.2.1/data --basedir=/usr/local/mysql.2.1

注意:會得到一個初始化密碼一定要記住,要不然連不上資料庫

8.切換到mysql.2.1/bin目錄下執行

./mysql_ssl rsa_setsetup  --datadir=/usr/local/mysql.2.1/data

9.更改mysql.2.1整個檔案夾的許可權

chown -R mysql: mysql /usr/local/mysql.2.1

10.啟動mysql服務

./mysqld_safe &  (&表示後台啟動)

11.切換到mysql.2.1/bin目錄下執行登陸

./mysql -uroot -p

輸入第七步產生的臨時密碼

12.執行sql語句show database,會出現錯誤,提示修改密碼

alter user ‘root‘@‘localhost‘ indentified by ‘123456‘

13.授權遠端存取

grant all privileges on *.* to [email protected]‘%‘ indentified by ‘123456‘

第一個*號表示所有資料庫名

第二個*號表示所有資料庫表

 [email protected]‘%‘:root 表示使用者名稱  %表示ip地址,比如[email protected],[email protected]

14.執行重新整理許可權命令

flush privileges

linux下配置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.