ubuntu 離線包安裝mysql

1 Preliminary Note

Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typingmysql

sudo su

2 Disabling AppArmor

Your manually installed MySQL 5.6.8 might refuse to start if AppArmor is running, therefore we disable AppArmor: linux

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get remove apparmor apparmor-utils

3 Installing MySQL 5.6.8rc1 (Linux Generic)

First we create a user and group called mysql:sql

groupadd mysql
useradd -r -g mysql mysql

Next install the libaio1 package:數據庫

apt-get install libaio1

Next:下載和安裝app

下載:能夠在Oracle 官網下載離線包:我下載的爲mysql-5.6.12-linux-glibc2.5-i686.tar.gzide

將離線包複製到 /usr/local下this

Unpack MySQL, rename the directory to mysql, and make it owned by the user and group mysql:spa

tar xvfz mysql-5.6.12-linux-glibc2.5-i686.tar.gz
mv mysql-5.6.12-linux-glibc2.5-i686 mysql
cd mysql
chown -R mysql .
chgrp -R mysql .

Runserver

scripts/mysql_install_db --user=mysql

在這裏可能會出現錯誤:ip

Installing MySQL system tables..../bin/mysqld: error whileloading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory

解決辦法:

這說明還要安裝一個libaio的依賴庫:
sudo apt-get install libaio-dev

而後從新執行:

scripts/mysql_install_db --user=mysql

to create the necessary databases (like the mysql database):


Change some ownerships:

chown -R root .
chown -R mysql data

MySQL uses the my.cnf file inside /usr/local/mysql, so we don't have to create one on our own. If you want to change MySQL settings, you can do it in that file.

The downloaded MySQL package comes with the init script mysql.server which we copy to /etc/init.d as follows:

cp support-files/mysql.server /etc/init.d/mysql.server

It is already executable, so we don't have to change permissions.

We can now start MySQL 5.6 as follows:

/etc/init.d/mysql.server start

To make MySQL start automatically at boot time, run the following command:

update-rc.d mysql.server defaults

The MySQL commands (like mysql, mysql_secure_installation, etc.) are located in the /usr/local/mysql/bin directory which is not in the PATH which means we would have to call these commands with the full or relative path which is cumbersome. To avoid this, we create the following symlink so that we can call all MySQL commands without a path:


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

Finally, we should set a MySQL root password:


mysql_secure_installation

root@server1:/usr/local/mysql# mysql_secure_installation



啓動MySQL服務:                       sudo start mysql

      中止MySQL服務:                       sudo stop mysql

修改 MySQL 的管理員密碼:     sudo mysqladmin -u root password newpassword

      設置遠程訪問(正常狀況下,mysql佔用的3306端口只是在IP 127.0.0.1上監聽,拒絕了其餘IP的訪問(經過netstat能夠查看到)。取消本地監

    聽須要修改 my.cnf 文件:):    

      sudo vi /etc/mysql/my.cnf

      bind-address = 127.0.0.1 //找到此內容而且註釋


4)MySQL安裝後的目錄結構分析(此結構只針對於使用apt-get install 在線安裝狀況):

     數據庫存放目錄:              /var/lib/mysql/

     相關配置文件存放目錄:          /usr/share/mysql

     相關命令存放目錄:             /usr/bin(mysqladmin mysqldump等命令)

     啓動腳步存放目錄:            /etc/rc.d/init.d/


5)MySQL圖形化管理軟件

     通常使用的有兩個比較好,一個開源,一個商業收費:

    開源:MySQL Workbench   (具體使用介紹隨着個人使用,我會慢慢總結)

    商業:Navicat (收費的,有30天體驗,以後我相信你們會有辦法的)

相關文章
相關標籤/搜索