Linux下安裝mysql 5.7

來源:互聯網
上載者:User

標籤:set   root   mys   初始密碼   image   default   /etc/   err   複製   

1.上傳tar包到伺服器並解壓tar包到/usr/local/目錄 

 cd /usr/local/ 

tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar 

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

mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql 

2.建立運行MySQL的使用者和組(名字可以任意)

 Shell> groupadd mysql 

 Shell> useradd mysql -g mysql 

3.切換到mysql目錄 

 Shell > mkdir data 

4.修改解壓包的許可權 

 Shell> chown –R mysql

Shell> chgrp –R mysql 

5.安裝MySQL 

 Shell> bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ##初始化資料目 錄 

 shell> cp -f support-files/my-default.cnf /etc/my.cnf  ##將預設設定檔複製到指定目錄 

 shell> bin/mysqld_safe --datadir=/usr/local/mysql/data --user=mysql & ##啟動MySQL服務 

shell> cp support-files/mysql.server /etc/init.d/mysql.server ##將MySQL加入到服務自啟動 

Shell> /etc/init.d/mysql.server start ##通過服務啟動MySQL   


啟動過程中如果碰到如下錯誤 

 [[email protected] mysql]# bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ? bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

 則需要安裝包yum install -y libaio 

初始化過程中獲得root的初始密碼

 

 

 

修改root的初始密碼

mysql> set password=password(‘mysql‘); ? Query OK, 0 rows affected, 1 warning (0.01 sec)
 
mysql> flush privileges; ? Query OK, 0 rows affected (0.00 sec)

 

Linux下安裝mysql 5.7

聯繫我們

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