CentOS7安裝mysql

來源:互聯網
上載者:User

標籤:mysql

6. 安裝mysql

# 配置環境變數,並立即更新

vi /etc/profile

export MYSQL_HOME="/usr/local/mysql"

export PATH="$PATH:$MYSQL_HOME/bin"

source /etc/profile

wget http://120.52.72.24/cdn.mysql.com/c3pr90ntc0td//Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz -O /usr/local/src #glibc是編譯過後的版本,不需要make install

cd /usr/local/src

tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

mv /usr/local/src/mysql-5.7.16-linux-glibc2.5-x86_64 $MYSQL_HOME

chown -R mysql:mysql $MYSQL_HOME #更改$MYSQL_HOME許可權為mysql:mysql

groupadd mysql #添加使用者組mysql

useradd -r -g mysql mysql -d $MYSQL_HOME #添加使用者mysql,指定其使用者組是mysql,home路徑是$MYSQL_HOME

passwd mysql #設定mysql使用者的登陸密碼

yum install -y perl-Module-Install.noarch

$MYSQL_HOME/bin/mysqld --initialize --explicit_defaults_for_timestamp --user=mysql --basedir=$MYSQL_HOME --datadir=$MYSQL_HOME/data #第一次啟動


2016-12-08T05:12:08.916945Z 0 [Warning] InnoDB: New log files created, LSN=45790

2016-12-08T05:12:08.993901Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2016-12-08T05:12:09.048289Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: de6b7880-bd04-11e6-8efb-080027798ca2.

2016-12-08T05:12:09.048994Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.

2016-12-08T05:12:09.049893Z 1 [Note] A temporary password is generated for [email protected]: 0w=a_KV.gT_k


cp $MYSQL_HOME/support-files /etc/my.cnf #mysql服務啟動設定檔

cp $MYSQL_HOME/support-files/mysql.server /etc/init.d/mysql #將mysql加入到可控制啟動的服務的檔案夾內,並命名mysql,即service可控制的服務名,至此可用service mysql start控制啟動mysql

chkconfig --add mysql

chkconfig mysql on

service mysql start

mysql -u root -p

輸入密碼:0w=a_KV.gT_k

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; #第一次改密碼為‘123456‘

mysqladmin -uroot -p123456 password ‘123‘ #第二次及以後改密碼


本文出自 “12382059” 部落格,請務必保留此出處http://12392059.blog.51cto.com/12382059/1880864

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.