Ubuntu下安裝MySQL離線包及相關配置

來源:互聯網
上載者:User

Ubuntu下安裝MySQL三種方式:

  1. 從網上安裝 sudo apt-get install mysql-server。裝完已經自動設定好環境變數,可以直接使用mysql的命令

  2. 安裝離線包,以mysql-5.0.45-linux-i686-icc-glibc23.tar.gz為例。

  3. 二進位包安裝:安裝完成已經自動設定好環境變數,可以直接使用mysql命令

網上安裝和二進位包安裝比較簡單,重點說Ubuntu下安裝MySQL離線包。

  1. groupadd mysql

  2. mkdir /home/mysql

  3. useradd -g mysql -d /home/mysql mysql

  4. copy mysql-5.0.45-linux-i686-icc-glibc23.tar.gz到/usr/local目錄

  5. 解壓:tar zxvf mysql-5.0.45-linux-i686-icc-glibc23.tar.gz

  6. ln -s mysql-5.0.45-linux-i686-icc-glibc23 mysql

  7. cd /usr/local/mysql

  8. chown -R mysql .

  9. chgrp -R mysql .

  10. scripts/mysql_install_db --user=mysql (一定要在mysql目錄下執行,注意輸出的文字,裡邊有修改root密碼和啟動mysql的命令)

  11. 為root設定密碼: ./bin/mysqladmin -u root password 'passw0rd'

配置和管理msyql:

  1. 修改mysql最大串連數:cp support-files/my-medium.cnf ./my.cnf,vim my.cnf,增加或修改max_connections=1024

  關於my.cnf:mysql按照下列順序搜尋my.cnf:/etc,mysql安裝目錄,安裝目錄下的data。/etc下的是全域設定。

  2. 啟動mysql:/usr/local/mysql/bin/mysqld_safe --user=mysql &

  3. 停止mysql:mysqladmin -uroot -ppassw0rd shutdown 注意,u,p後沒有空格

  4. 設定mysql自啟動:把啟動命令加入/etc/rc.local檔案中

  5. 允許root遠程登陸:

  1)本機登陸mysql:mysql -u root -p (-p一定要有);改變資料庫:use mysql;

  2)從所有主機:grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;

  3)從指定主機:grant all privileges on *.* to root@"192.168.11.205" identified by "passw0rd" with grant option; flush privileges;

  4) 進mysql庫查看host為%的資料是否添加:use mysql; select * from user;

  6. 建立資料庫,建立user:

  1) 建庫:create database test1;

  2) 建使用者,賦權:grant all privileges on test1.* to user_test@"%" identified by "passw0rd" with grant option;

  3)刪除資料庫:drop database test1;

  • 1
  • 2
  • 下一頁

聯繫我們

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