centos 7.3 安裝 mysql-5.7.18-linux-glibc2.5-x86_64

來源:互聯網
上載者:User

標籤:centos 7.3   安裝   mysql5.7   

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz   大概有600M  可以選擇迅雷下載然後進行上傳 ,因為是內網 ,我就選擇迅雷下載 。。

 1、下載:

[[email protected] ~]#  wget  https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz 

2、解壓 :

tar  zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz -C /usr/local  --解壓到指定目錄 然後再進行重新命名 為mysql

3、建立mysql 賬戶 

1>.[[email protected] ~]#useradd -M -s /sbin/nologin  mysql   -- M 不建立使用者目錄

2>.[[email protected] ~]# mkdir -p /data/mysqldata

3>.[[email protected] ~]# chown  -R mysql:mysql /data/mysqldata  --將mysqldata所屬主所屬組賦予mysql使用者權限

4、進行初始化:

1>.[[email protected] ~]#cd /usr/local/mysql

2>.[[email protected] ~]#./bin/mysqld  --initialize --user=mysql --datadir= /data/mysqldata  

注意,這一步最後一行會有一個提示
[Note] A temporary password is generated for [email protected]: -gLjbSisv1uh

5、拷貝設定檔和啟動指令碼

1>. 修改 /etc/my.cnf 檔案。

vim /etc/my.cnf //編輯或者修改

[mysqld]   --在這裡修改
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
socket = /tmp/mysql.sock     -注意路徑不能出錯,否則啟動出錯 


cp support-files/mysql.server /etc/init.d/mysqld   --複製啟動指令碼到/etc/init.d下
vi /etc/init.d/mysqld  --編輯或者修改
basedir=/usr/local/mysql
datadir=/data/mysqldata


錯誤提示:

[[email protected] support-files]# ./mysql.server start

Starting MySQL.2017-07-10T07:02:40.832128Z mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘, however file don‘t exists. Create writable for user ‘mysql‘.

 ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).


 解決方案:

因為前期未建立 /var/log/mariadb/mariadb.log‘ 下面的 mariadb目錄 ,mariadb.log 需要手工建立,完成 啟動成功。

6. 啟動服務
/etc/init.d/mysqld start

加入開機啟動
chkconfig --add mysqld
chkconfig mysqld on

7、設定root密碼

# ln -s /usr/local/mysql/bin/mysql /usr/bin 映射一個連結到/usr/bin目錄下,建立一個連結檔案。

mysql -uroot -p/進入mysql (密碼為剛剛安裝完成密碼-gLjbSisv1uh)

成功登陸後 ,在輸入show databases 會提示你重新設定密碼,

mysql>set password = password(‘mypass‘); 退出來,再使用新的密碼登入就可以了、

2>.還有一種情況,就是不知道初始化密碼
vi /etc/my.cnf
在[mysqld]下面增加一行
skip-grant-tables
重啟  /etc/init.d/mysqld restart

 mysql -uroot 

mysql> update user set authentication_string=password(‘123333‘) where user=‘root‘;
退出來後,更改my.cnf,去掉剛加的 skip-grant-tables
重啟 /etc/init.d/mysqld restart
此時就可以使用新的密碼了。

此時安裝完成mysql 5.7


本文出自 “hisus” 部落格,謝絕轉載!

centos 7.3 安裝 mysql-5.7.18-linux-glibc2.5-x86_64

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.