當前位置:首頁 » 操作系統 » linux安裝mysqlgz

linux安裝mysqlgz

發布時間: 2023-01-07 16:21:03

㈠ 怎麼在linux上安裝mysql

1. 運行平台:CentOS 6.3 x86_64,基本等同於RHEL 6.3
2. 安裝方法:
安裝MySQL主要有兩種方法:一種是通過源碼自行編譯安裝,這種適合高級用戶定製MySQL的特性,這里不做說明;另一種是通過編譯過的二進制文件進行安裝。二進制文件安裝的方法又分為兩種:一種是不針對特定平台的通用安裝方法,使用的二進制文件是後綴為.tar.gz的壓縮文件;第二種是使用RPM或其他包進行安裝,這種安裝進程會自動完成系統的相關配置,所以比較方便。
3. 下載安裝包:
a. 官方下載地址:
http://dev.mysql.com/downloads/mysql/#downloads
或鏡像文件下載:
http://dev.mysql.com/downloads/mirrors.html
2. 下載文件(根據操作系統選擇相應的發布版本):
a. 通用安裝方法
mysql-5.5.29-linux2.6-x86_64.tar.gz
b. RPM安裝方法:
MySQL-server-5.5.29-2.el6.x86_64.rpm
MySQL-client-5.5.29-2.el6.x86_64.rpm
4. 通用安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸:載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
b. 添加mysql組和mysql用戶,用於設置mysql安裝目錄文件所有者和所屬組。
[root@localhost JavaEE]#groupadd mysql
[root@localhost JavaEE]#useradd -r -g mysql mysql
*useradd -r參數表示mysql用戶是系統用戶,不可用於登錄系統。
c. 將二進制文件解壓到指定的安裝目錄,我們這里指定為/usr/local
[root@localhost ~]# cd/usr/local/
[root@localhost local]#tar zxvf /path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz
*加壓後在/usr/local/生成了解壓後的文件夾mysql-5.5.29-linux2.6-x86_64,這名字太長,我們為它建立一個符號鏈接mysql,方便輸入。
[root@localhost local]#ln -s mysql-5.5.29-linux2.6-x86_64 mysql
d. /usr/local/mysql/下的目錄結構

Directory

Contents of Directory

bin

Client programs and the mysqld server

data

Log files, databases

docs

Manual in Info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

scripts

mysql_install_db

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

sql-bench

Benchmarks

e. 進入mysql文件夾,也就是mysql所在的目錄,並更改所屬的組和用戶。
[root@localhost local]#cd mysql
[root@localhost mysql]#chown -R mysql .
[root@localhost mysql]#chgrp -R mysql .
f. 執行mysql_install_db腳本,對mysql中的data目錄進行初始化並創建一些系統表格。注意mysql服務進程mysqld運行時會訪問data目錄,所以必須由啟動mysqld進程的用戶(就是我們之前設置的mysql用戶)執行這個腳本,或者用root執行,但是加上參數--user=mysql。
[root@localhost mysql]scripts/mysql_install_db --user=mysql
*如果mysql的安裝目錄(解壓目錄)不是/usr/local/mysql,那麼還必須指定目錄參數,如
[root@localhost mysql]scripts/mysql_install_db --user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
*將mysql/目錄下除了data/目錄的所有文件,改回root用戶所有,mysql用戶只需作為mysql/data/目錄下所有文件的所有者。
[root@localhost mysql]chown -R root .
[root@localhost mysql]chown -R mysql data
g. 復制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
h. 將mysqld服務加入開機自啟動項。
*首先需要將scripts/mysql.server服務腳本復制到/etc/init.d/,並重命名為mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通過chkconfig命令將mysqld服務加入到自啟動服務項中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服務名稱mysqld就是我們將mysql.server復制到/etc/init.d/時重命名的名稱。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
i. 重啟系統,mysqld就會自動啟動了。
*檢查是否啟動
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新啟動,那可以直接手動啟動。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
j. 運行客戶端程序mysql,在mysql/bin目錄中,測試能否連接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此時會出現mysql>命令提示符,可以輸入sql語句,輸入quit或exit退出。為了避免每次都輸入mysql的全路徑/usr/local/mysql/bin/mysql,可將其加入環境變數中,在/etc/profile最後加入兩行命令:
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
這樣就可以在shell中直接輸入mysql命令來啟動客戶端程序了
[root@localhost mysql]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>

5. RPM安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2. 安裝MySQL的伺服器端軟體,注意切換到root用戶:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安裝完成後,安裝進程會在Linux中添加一個mysql組,以及屬於mysql組的用戶mysql。可通過id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL伺服器安裝之後雖然配置了相關文件,但並沒有自動啟動mysqld服務,需自行啟動:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通過檢查埠是否開啟來查看MySQL是否正常啟動:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
c. 安裝MySQL的客戶端軟體:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安裝成功應該可以運行mysql命令,注意必須是mysqld服務以及開啟:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
d. RPM安裝方式文件分布

Directory

Contents of Directory

/usr/bin

Client programs and scripts

/usr/sbin

The mysqld server

/var/lib/mysql

Log files, databases

/usr/share/info

Manual in Info format

/usr/share/man

Unix manual pages

/usr/include/mysql

Include (header) files

/usr/lib/mysql

Libraries

/usr/share/mysql

Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation

/usr/share/sql-bench

Benchmarks

㈡ 怎麼在linux上安裝mysql

你好,安裝步驟如下:
第一步:進入mysql官方網站

2
第二步:選擇MySQL Community Server(GPL)

3
第三步:進入下載頁面,會看到Mysql Community Server 5.6.17選擇自己的linux版本,我的是ubuntu14.04,選擇Linux-Generic,把頁面往下翻,選擇Linux-Generic(glibc 2.5)(x86,64-bit), Compressed TAR Archive下載

4
第四步:點擊下載之後會出現oracle的登陸界面,注冊用戶後登陸oracle賬號,即可免費下載mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz

5
第五步:下載之後文件在/home/liubei/下載 目錄下,打開命令行,對文件夾進行解壓,給這么長的文件夾起個別名,找到mysql提供的官方安裝指導,具體代碼:

第五步代碼:
shell>cd /usr/local
shell>sudo tar zxvf /home/liubei/下載/mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz
shell>sudo ln -s mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz mysql
shell>cd mysql
shell>ls

第六步:通過上面的操作你就能看到mysql文件夾裡面的INSTALL-BINARY文件,用gedit將其打開,代碼如下
第六步代碼:
shell>gedit INSTALL-BINARY
第七步:這個文檔中會有如下圖所示的一段代碼,如下,接下來我分析文檔里的代碼,和我自己安裝過程中的一些問題,和我的安裝代碼
第八步:
文檔安裝代碼:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysqlshell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
第九步:
文檔安裝代碼中每一行的意思:
shell> groupadd mysql //在/etc/group文件中添加mysql的記錄
shell> useradd -r -g mysql mysql
shell> cd /usr/local //打開/usr/local目錄
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz // /path/to/mysql-VERSION-OS.tar.gz指下載的文件的具體路徑我的是 /home/liubei/下載/mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz
//這個步驟解壓下載的mysql壓縮文件到/usr/local文件夾下
shell> ln -s full-path-to-mysql-VERSION-OS mysql //為很長的文件夾取個別名並創建鏈接
shell> cd mysql //打開mysql文件夾
shell> chown -R mysql . //注意後面有個點,意思是把文件夾的own許可權賦予mysql用戶shell> chgrp -R mysql . //後面也有點,意思是把文件夾的grp許可權賦予mysql用戶,文件夾的許可權可以通過
shell>ls -la查看
shell> scripts/mysql_install_db --user=mysql //通過mysql用戶安裝mysql
shell> chown -R root . //把文件夾的own許可權賦予root
shell> chown -R mysql data //把data文件夾的own許可權賦予mysql
shell> bin/mysqld_safe --user=mysql &//啟動mysql
shell> cp support-files/mysql.server /etc/init.d/mysql.server //復制mysql.server文件到/etc/init.d目錄下

第十步:因為我是新裝的ubuntu系統,所以在安裝過程中遇到很多問題,按教程中的不能完全成功,接下來貼出我自己的安裝命令:
第十步安裝命令:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> sudo scripts/mysql_install_db --user=mysql
這一步之後sudo gedit my.cnf
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql --datadir=/usr/local/mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
第十一步:
各行中的命令的意思:
shell> groupadd mysqlshell> useradd -r -g mysql mysqlshell> cd /usr/local
//實際在做解壓到/usr/local目錄下是需要管理員許可權的如下:
shell>sudo tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> sudo ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
//給文件夾賦予許可權的命令都需要管理員許可權shell> sudo chown -R mysql .
shell> sudo chgrp -R mysql .
shell> sudo scripts/mysql_install_db --user=mysql
//新系統在執行上面這行代碼時會報錯,按照報錯中的提示安裝所需插件即可
//這一步之後sudo gedit my.cnf ,修改mysql的啟動信息,如下圖所示
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql --datadir=/usr/local/mysql/data &
//上面這步總是報錯後在後面加上 --datadir參數後成功啟動mysql
//這一步進行後即可成功啟動mysql,輸入
shell>mysql
如果出現如下圖所示,即啟動mysql成功
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

第十二步:
另外:關閉mysql的命令
shell>sudo service mysqld stop
然後啟動mysql的命令
shell> sudo service mysqld start

㈢ linux上怎麼安裝mysql

1. 運行平台:CentOS 6.3 x86_64,基本等同於RHEL 6.3
2. 安裝方法:
安裝MySQL主要有兩種方法:一種是通過源碼自行編譯安裝,這種適合高級用戶定製MySQL的特性,這里不做說明;另一種是通過編譯過的二進制文件進行安裝。二進制文件安裝的方法又分為兩種:一種是不針對特定平台的通用安裝方法,使用的二進制文件是後綴為.tar.gz的壓縮文件;第二種是使用RPM或其他包進行安裝,這種安裝進程會自動完成系統的相關配置,所以比較方便。
3. 下載安裝包:
2. 下載文件(根據操作系統選擇相應的發布版本):
a. 通用安裝方法
mysql-5.5.29-linux2.6-x86_64.tar.gz
b. RPM安裝方法:
MySQL-server-5.5.29-2.el6.x86_64.rpm
MySQL-client-5.5.29-2.el6.x86_64.rpm
4. 通用安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸:載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
b. 添加mysql組和mysql用戶,用於設置mysql安裝目錄文件所有者和所屬組。
[root@localhost JavaEE]#groupadd mysql
[root@localhost JavaEE]#useradd -r -g mysql mysql
*useradd -r參數表示mysql用戶是系統用戶,不可用於登錄系統。
c. 將二進制文件解壓到指定的安裝目錄,我們這里指定為/usr/local
[root@localhost ~]# cd/usr/local/
[root@localhost local]#tar zxvf /path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz
*加壓後在/usr/local/生成了解壓後的文件夾mysql-5.5.29-linux2.6-x86_64,這名字太長,我們為它建立一個符號鏈接mysql,方便輸入。
[root@localhost local]#ln -s mysql-5.5.29-linux2.6-x86_64 mysql
d. /usr/local/mysql/下的目錄結構

Directory

Contents of Directory

bin

Client programs and the mysqld server

data

Log files, databases

docs

Manual in Info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

scripts

mysql_install_db

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

sql-bench

Benchmarks

e. 進入mysql文件夾,也就是mysql所在的目錄,並更改所屬的組和用戶。
[root@localhost local]#cd mysql
[root@localhost mysql]#chown -R mysql .
[root@localhost mysql]#chgrp -R mysql .
f. 執行mysql_install_db腳本,對mysql中的data目錄進行初始化並創建一些系統表格。注意mysql服務進程mysqld運行時會訪問data目錄,所以必須由啟動mysqld進程的用戶(就是我們之前設置的mysql用戶)執行這個腳本,或者用root執行,但是加上參數--user=mysql。
[root@localhost mysql]scripts/mysql_install_db --user=mysql
*如果mysql的安裝目錄(解壓目錄)不是/usr/local/mysql,那麼還必須指定目錄參數,如
[root@localhost mysql]scripts/mysql_install_db --user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
*將mysql/目錄下除了data/目錄的所有文件,改回root用戶所有,mysql用戶只需作為mysql/data/目錄下所有文件的所有者。
[root@localhost mysql]chown -R root .
[root@localhost mysql]chown -R mysql data
g. 復制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
h. 將mysqld服務加入開機自啟動項。
*首先需要將scripts/mysql.server服務腳本復制到/etc/init.d/,並重命名為mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通過chkconfig命令將mysqld服務加入到自啟動服務項中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服務名稱mysqld就是我們將mysql.server復制到/etc/init.d/時重命名的名稱。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
i. 重啟系統,mysqld就會自動啟動了。
*檢查是否啟動
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新啟動,那可以直接手動啟動。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
j. 運行客戶端程序mysql,在mysql/bin目錄中,測試能否連接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此時會出現mysql>命令提示符,可以輸入sql語句,輸入quit或exit退出。為了避免每次都輸入mysql的全路徑/usr/local/mysql/bin/mysql,可將其加入環境變數中,在/etc/profile最後加入兩行命令:
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
這樣就可以在shell中直接輸入mysql命令來啟動客戶端程序了
[root@localhost mysql]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>

5. RPM安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2. 安裝MySQL的伺服器端軟體,注意切換到root用戶:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安裝完成後,安裝進程會在Linux中添加一個mysql組,以及屬於mysql組的用戶mysql。可通過id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL伺服器安裝之後雖然配置了相關文件,但並沒有自動啟動mysqld服務,需自行啟動:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通過檢查埠是否開啟來查看MySQL是否正常啟動:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
c. 安裝MySQL的客戶端軟體:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安裝成功應該可以運行mysql命令,注意必須是mysqld服務以及開啟:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>

㈣ 怎麼在linux下安裝mysql

怎麼在linux下安裝mysql
安裝包:mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

使用xshell連接linux伺服器,使用root用戶名登錄,依次執行以下命令:

======================================================

/usr/sbin/groupadd mysql 【添加mysql組】

/usr/sbin/useradd -d /var/lib/mysql -s /sbin/nologin -g mysql mysql

mkdir -p /usr/local/src/mysql 【新建mysql文件夾】

cd / 【打開上傳安裝包的目錄】

mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 【上傳安裝包到伺服器的根目錄下】

mv mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz /usr/local/src/mysql【根目錄的安裝包移動到文件夾下】

cd /usr/local/src/mysql【打開目錄】

tar -zxvf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz【解壓安裝包】

cp mysql-5.6.30-linux-glibc2.5-x86_64 /usr/local/mysql -r【復制文件】

cd /usr/local【打開目錄】

chown -R mysql:mysql mysql/

cd /usr/local/mysql/scripts/【打開目錄】

./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data【執行腳本】

cd /usr/local/mysql/support-files【打開目錄】

cp my-default.cnf /etc/my.cnf【復制文件到新的路徑下及文件名】

cp: overwrite `/etc/my.cnf'?Y【Y】

cp mysql.server /etc/init.d/mysql【復制文件到新的路徑下】

vim /etc/profile【編輯軟體運行環境】
vim i(編輯一些內容) esc(進入normal) w(保存文件) q(不保存退出文件)

㈤ 如何在linux下安裝mysql

到mysql官網下載mysql編譯好的二進制安裝包,在下載頁面Select Platform:選項選擇linux-generic,然後把頁面拉到底部,64位系統下載Linux - Generic (glibc 2.5) (x86, 64-bit),32位系統下載Linux - Generic (glibc 2.5) (x86, 32-bit)
linux系統安裝mysql
linux系統安裝mysql
解壓32位安裝包:
進入安裝包所在目錄,執行命令:tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz
linux系統安裝mysql
復制解壓後的mysql目錄到系統的本地軟體目錄:
執行命令:cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
注意:目錄結尾不要加/
添加系統mysql組和mysql用戶:
執行命令:groupadd mysql和useradd -r -g mysql mysql
安裝資料庫
進入安裝mysql軟體目錄:執行命令 cd /usr/local/mysql
修改當前目錄擁有者為mysql用戶:執行命令 chown -R mysql:mysql ./
安裝資料庫:執行命令 ./scripts/mysql_install_db --user=mysql
修改當前目錄擁有者為root用戶:執行命令 chown -R root:root ./
修改當前data目錄擁有者為mysql用戶:執行命令 chown -R mysql:mysql data
到此資料庫安裝完畢
啟動mysql服務和添加開機啟動mysql服務:
添加開機啟動:執行命令cp support-files/mysql.server /etc/init.d/mysql,把啟動腳本放到開機初始化目錄
啟動mysql服務:執行命令service mysql start
執行命令:ps -ef|grep mysql 看到mysql服務說明啟動成功,如圖
修改mysql的root用戶密碼,root初始密碼為空的:
執行命令:./bin/mysqladmin -u root password '密碼'
把mysql客戶端放到默認路徑:
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
注意:建議使用軟鏈過去,不要直接包文件復制,便於系統安裝多個版本的mysql

㈥ linux伺服器上怎麼安裝mysql

安裝包:mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

使用xshell連接linux伺服器,使用root用戶名登錄,依次執行以下命令:

======================================================

/usr/sbin/groupadd mysql 【添加mysql組】

/usr/sbin/useradd -d /var/lib/mysql -s /sbin/nologin -g mysql mysql

mkdir -p /usr/local/src/mysql 【新建mysql文件夾】

cd / 【打開上傳安裝包的目錄】

mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 【上傳安裝包到伺服器的根目錄下】

mv mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz /usr/local/src/mysql【根目錄的安裝包移動到文件夾下】

cd /usr/local/src/mysql【打開目錄】

tar -zxvf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz【解壓安裝包】

cp mysql-5.6.30-linux-glibc2.5-x86_64 /usr/local/mysql -r【復制文件】

cd /usr/local【打開目錄】

chown -R mysql:mysql mysql/

cd /usr/local/mysql/scripts/【打開目錄】

./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data【執行腳本】

cd /usr/local/mysql/support-files【打開目錄】

cp my-default.cnf /etc/my.cnf【復制文件到新的路徑下及文件名】

cp: overwrite `/etc/my.cnf'?Y【Y】

cp mysql.server /etc/init.d/mysql【復制文件到新的路徑下】

vim /etc/profile【編輯軟體運行環境】
vim i(編輯一些內容) esc(進入normal) w(保存文件) q(不保存退出文件)
###############################################################
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
###############################################################
source /etc/profile

chkconfig --add mysql

chkconfig mysql on

service mysql start
/usr/local/mysql/bin/mysqladmin -u root password 'rootroot'【修改資料庫root的密碼】

grant all privileges on tdcdb.* to 'root'@'%' identified by 'rootroot' 【給mysql用戶分配許可權】
flush privileges;

vim /etc/sysconfig/iptables【編輯訪問埠號】
###############################################################
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(添加3306的埠號)
###############################################################
service iptables restart
netstat -ntlp

mysql -u root -p (命令未找到使用: ln -s /usr/local/mysql/bin/mysql /usr/bin)
create user 'tdc'@'%' identified by 'P@ssw0rd';【創建資料庫訪問用戶】
create database if not exists `tdcdb`;【創建資料庫】

grant all privileges on tdcdb.* to 'tdc'@'%' identified by 'P@ssw0rd';【給tdc用戶分配訪問密碼】
flush privileges;

vi /etc/my.cnf【編輯配置文件,支持語言設置】
###############################
[client]
default-character-set=utf8

[mysqld]
character-set-server=utf8

[mysql]
default-character-set=utf8
###############################
service mysql stop【重新啟動mysql服務】
service mysql start

======================================================

linux 常用命令:

pwd:查看當前路徑

ll:2個小寫的L,查看當前目錄下的所有文件

cd:打開目錄,包括路徑地址及文件夾

vi 文件名:編輯linux下的文件,使用大寫的【I】命令來進行編輯,編輯完成後點擊【ESC】按鈕跳出編輯,輸入【:wq!】命令來退出保存;

注意:linux的文件不能打開直接修改,只能通過vi命令進行修改

======================================================

卸載程序的方式:

ps -ef | grep mysql
/etc/init.d/mysql status
whereis mysql
find / -name mysql【找到所有文件名為mysql的文件列表】
rm -rf /usr/local/mysql/【使用rm命令來移除列表中的文件】
rm -rf /etc/my.cnf【使用rm命令來移除列表中的文件】

㈦ linux下的mysql客戶端怎麼安裝

linux安裝mysql服務分兩種安裝方法:

①源碼安裝,優點是安裝包比較小,只有十多M,缺點是安裝依賴的庫多,安裝編譯時間長,安裝步驟復雜容易出錯;

②使用官方編譯好的二進制文件安裝,優點是安裝速度快,安裝步驟簡單,缺點是安裝包很大,300M左右。以下介紹linux使用官方編譯好的二進制包安裝mysql。

㈧ 在linux中怎麼安裝mysql

到mysql官網下載mysql編譯好的二進制安裝包

解壓32位安裝包:
進入安裝包所在目錄,執行命令:tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz

復制解壓後的mysql目錄到系統的本地軟體目錄:
執行命令:cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
注意:目錄結尾不要加/

添加系統mysql組和mysql用戶:
執行命令:groupadd mysql和useradd -r -g mysql mysql

安裝資料庫:
進入安裝mysql軟體目錄:執行命令 cd /usr/local/mysql
修改當前目錄擁有者為mysql用戶:執行命令 chown -R mysql:mysql ./
安裝資料庫:執行命令 ./scripts/mysql_install_db --user=mysql
修改當前目錄擁有者為root用戶:執行命令 chown -R root:root ./
修改當前data目錄擁有者為mysql用戶:執行命令 chown -R mysql:mysql data
到此資料庫安裝完畢

㈨ 怎樣在Linux環境下安裝部署MySQL資料庫系統

在Linux安裝軟體需要預先做好如下一些准備:准備好Linux操作系統如:CentOS7。配置好yum源。
完成上述准備後,就可以動手安裝MySQL資料庫了。主要安裝步驟如下:
1. 禁用selinux
setenforce 0
2. 上傳安裝文件到Linux
3.解壓rpm包
tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
4.安裝軟體
yum install mysql-community-{libs,client,common,server}-*.rpm
5.啟動mysql資料庫初始化
systemctl start mysqld
6.修改vi /etc/my.cnf
添加:
[mysqld]
#可以在表中錄入中文
character-set-server=utf8 #
explicit-defaults-for-timestamp
# 禁用當前密碼認證策略,可以使用簡單密碼(生產環境不適用)
validate_password=0
7.重啟mysql服務
systemctl restart mysqld
8.找臨時登錄密碼
grep -i "temporary password" /var/log/mysqld.log
9.連接MySQL資料庫
mysql -uroot -p 輸入臨時密碼
10.修改root用戶登錄密碼為簡單密碼(生產環境不適用)
alter user root@localhost identified by '';
11.配置MYSQL_PS1環境變數
修改家目錄下:.bash_profile文件,添加
export MYSQL_PS1="\u@\h[\d]>"
12.使新環境變數生效
source /root/.bash_profile
13.重新連接mysql驗證
mysql -uroot -p
除了上述安裝方式以外,可能在公司中會遇到安裝指定版本的需求,那麼如何安裝指定版本的MySQL數據呢?這時我們可以採用下載指定版本安裝包進行安裝的方式,主要步驟如下,假設CentOS7 linux最小安裝,已經配置好yum。首先檢查是否安裝numactl包
rpm -qa|grep numactl
yum install numactl-libs-* # 如果沒有安裝需要安裝。檢查是否安裝lio包
rpm -qa|grep lio
yum install lio-* # 如果沒有安裝需要安裝
具體安裝步驟如下:
* 禁用selinux
setenforce 0
* 上傳安裝文件到Linux
mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
* 創建mysql用戶組和用戶
groupadd -g 27 -r mysql
#-r創建系統賬戶,-M 不創建用戶家目錄 -N 不創建和用戶名一樣的用戶組
useradd -M -N -g mysql -r -s /bin/false -c "MySQL Server" -u 27 mysql
id mysql
* 上傳安裝包到root家目錄
* 解壓二進制文件到/usr/local
tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local
* 解壓目錄改名為mysql
cd /usr/local
ls -l
mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql
* 環境變數中添加mysql/bin目錄
vi /root/.bash_profile
修改PATH=/usr/local/mysql/bin:$PATH:$HOME/bin
添加 export MYSQL_PS1="\u@\h[\d]>"
source /root/.bash_profile
* 創建/usr/local/mysql/etc/my.cnf選項文件 (也可以使用默認的/etc/my.cnf選項文件)
mkdir -p /usr/local/mysql/etc
mkdir -p /usr/local/mysql/mysql-files
* 編輯選項文件my.cnf填寫默認選項
vi /usr/local/mysql/etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
log-error=/usr/local/mysql/data/mysqld.err
pid-file=/usr/local/mysql/data/mysqld.pid
secure_file_priv=/usr/local/mysql/mysql-files
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
Explicit-defaults-for-timestamp
character-set-server=utf8
[mysql]
socket=/usr/local/mysql/data/mysql.sock
* 初始化數據目錄
cd /usr/local/mysql
mkdir data
chmod 750 data
chown mysql:mysql data
* 初始化資料庫
cd /usr/local/mysql
bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --initialize
* 使用systemd管理mysql
例如:systemctl {start|stop|restart|status} mysqld
cd /usr/lib/systemd/system
touch mysqld.service
chmod 644 mysqld.service
vi mysqld.service
# 添加以下內容
[Unit]
Description=MySQL Server
Documentation=man:mysqld(7)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
Type=forking
PIDFile=/usr/local/mysql/data/mysqld.pid
# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0
# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --daemonize --pid-file=/usr/local/mysql/data/mysqld.pid $MYSQLD_OPTS
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql
# Sets open_files_limit
LimitNOFILE = 65535
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false
以上內容中注意:The --pid-file option specified in the my.cnf configuration file is ignored by systemd.
默認:LimitNOFILE = 5000,如果連接數(max_connection)需要調大,可以將LimitNOFILE 設置為最大65535
* 創建mysql.conf文件
cd /usr/lib/tmpfiles.d
#Add a configuration file for the systemd tmpfiles feature. The file is named mysql.conf and is placed in /usr/lib/tmpfiles.d.
cd /usr/lib/tmpfiles.d
touch mysql.conf
chmod 644 mysql.conf
* mysql.conf添加內容
vi mysql.conf
添加以下語句:
d /usr/local/mysql/data 0750 mysql mysql -
* 使新添加的mysqld服務開機啟動
systemctl enable mysqld.service
* 手動啟動mysqld
systemctl start mysqld
systemctl status mysqld
* 獲得mysql臨時登錄密碼
cat /usr/local/mysql/data/mysqld.err | grep "temporary password"
* 客戶端登錄連接mysql伺服器
mysql -uroot -p
輸入臨時密碼
* 修改MySQL用戶root@localhost密碼
mysql> alter user root@localhost identified by ''; #此處為了方便設置為空密碼
* 測試新密碼連接MySQL服務
mysql -uroot -p
至此,我們就完成了在Linux環境下安裝MySQL的任務。通過這兩種方式我們可以體會到在Linux環境下安裝軟體的基本思路及方法。

熱點內容
內到內演算法 發布:2025-05-14 07:29:11 瀏覽:33
文件夾名字不顯示 發布:2025-05-14 07:27:47 瀏覽:773
oracle的資料庫驅動jar 發布:2025-05-14 07:23:20 瀏覽:553
我的世界電腦版伺服器手機版能進嗎 發布:2025-05-14 07:22:01 瀏覽:678
達內培訓php多少錢 發布:2025-05-14 07:19:10 瀏覽:26
python位元組轉字元串 發布:2025-05-14 07:06:35 瀏覽:421
subplotpython 發布:2025-05-14 06:53:51 瀏覽:661
豎屏大屏導航工廠密碼一般是多少 發布:2025-05-14 06:49:29 瀏覽:806
如何在手機里設置無線網密碼 發布:2025-05-14 06:47:54 瀏覽:120
動態ip文件伺服器 發布:2025-05-14 06:44:22 瀏覽:891