Linux下安裝MySQL資料庫(壓縮包方式安裝)

來源:互聯網
上載者:User

標籤:修改   user   group   改密碼   ini   --   options   .com   report   

1、這裡我將Mysql安裝在/usr/local/mysql目錄裡面,也可以安裝在其他地方;

mkdir /usr/local/mysql

2、下載MySQL壓縮包

wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz 

3、解壓並複製

tar -xvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gzmv mysql-5.7.11-Linux-glibc2.5-x86_64/* /usr/local/mysql/

4、建立data目錄

mkdir /usr/local/mysql/data

5、建立mysql使用者組及其使用者

groupadd mysqluseradd -r -g mysql mysql

6、初始化資料

[[email protected] mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize2016-01-20 02:47:45 [WARNING] The bootstrap log isn‘t empty:2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

7、複製設定檔到 /etc/my.cnf

cp -a ./support-files/my-default.cnf /etc/my.cnf (選擇y) 

8、MySQL的服務指令碼放到系統服務中

cp -a ./support-files/mysql.server /etc/init.d/mysqld修改my.cnf檔案# These are commonly set, remove the # and set as required.basedir = /usr/local/mysqldatadir = /usr/local/mysql/dataport = 3306# server_id = .....socket = /tmp/mysql.sockcharacter-set-server = utf8# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M 

9、建立In

ln -s /usr/local/mysql/  /usr/bin/

10、啟動服務

service mysqld start 

11、初始化密碼

mysql5.7會產生一個初始化密碼,在root中.mysql_secret檔案中。

[[email protected] ~]# cat /root/.mysql_secret# Password set for user ‘[email protected]‘ at 2017-03-16 00:52:34 ws;fmT7yh0CM

12、登入並修改密碼

[[email protected] ~]# mysql -u root -palter user [email protected] identified by ‘tiger‘;

flush privileges;

13、退出重新登入,完成

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || sys                |+--------------------+4 rows in set (0.11 sec)

OK

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.