MySQL免編譯安裝及登入(5.6.36)
一、下載MySQL 5.6.36免編譯安裝包並上傳至 /usr/local/src 目錄(也可以使用wget命令直接下載至該目錄)
下載地址 https://yunpan.360.cn/surl_ymCGfFYt2Ya
二、解壓縮
[root@JSH-01 src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
三、將解壓縮後的檔案移動至 /usr/local/ 目錄下並改名為mysql
[root@JSH-01 src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
[root@JSH-01 local]# ls
aegis bin etc games include lib lib64 libexec mysql sbin share src
四、進入mysql目錄
[root@JSH-01 local]# cd mysql
[root@JSH-01 mysql]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
五、建立mysql使用者和SQL資料庫存放目錄
[root@JSH-01 mysql]# useradd mysql
[root@JSH-01 mysql]# mkdir /data
六、初始化安裝MySQL並制定使用者和目錄,安裝前需要先安裝相關的依賴包。
[root@JSH-01 mysql]# yum install -y perl gcc kernel-devel
[root@JSH-01 mysql]# yum install -y autoconf
[root@JSH-01 mysql]# yum install -y libaio
[root@JSH-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
執行完畢後輸入命令 echo$? 回車看輸出的結果是0還是1,如果是0則表示安裝成功。或者看到兩次 OK 也表示安裝成功。
[root@JSH-01 mysql]# echo $?
0
七、拷貝配置檔案和啟動指令碼
[root@JSH-01 mysql]# cp support-files/my-default.cnf /etc/my.cnf(拷貝配置檔案並改名為 my.cnf )
cp: overwrite ‘/etc/my.cnf’? y
[root@JSH-01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld(拷貝啟動指令碼並改名為 mysqld)
[root@JSH-01 mysql]# vi /etc/init.d/mysqld
拷貝完成之後編輯啟動指令碼mysqld並定義basedir 和 datadir
basedir=/usr/local/mysql
datadir=/data/mysql
八、儲存完畢啟動指令碼後將其許可權更改為 755(實際此檔案預設許可權就是 755)
[root@JSH-01 mysql]# ls -l /etc/init.d/mysqld 檢視檔案詳細資訊
-rwxr-xr-x 1 root root 10592 Nov 25 20:08 /etc/init.d/mysqld
九、設定MySQL開機啟動
[root@JSH-01 mysql]# chkconfig --add mysqld
[root@JSH-01 mysql]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use `systemctl list-unit-files`.
To see services enabled on particular target use
`systemctl list-dependencies [target]`.
aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
agentwatch 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
十、啟動MySQL服務
[root@JSH-01 mysql]# service mysqld start
Starting MySQL.Logging to `/data/mysql/JSH-01.err`.
[ OK ]
[root@JSH-01 mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3234/sshd
tcp6 0 0 :::3306 :::* LISTEN 22293/mysqld
由此可見MySQL使用的服務埠為3306
十一、如何停止MySQL服務
可以使用命令 killall mysqld 或者 service mysqld stop
十二、安裝完之後如何登入MySQL ?
[root@JSH-01 ~]# mysql -uroot
-bash: mysql: 未找到命令
提示未找到是因為mysql命令路徑為:/usr/local/mysql/bin/ 此時需要更改環境變數。編輯配置檔案 vi /etc/profile 將export PATH=$PATH:/usr/local/mysql/bin/寫入最後一行。
[root@JSH-01 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@JSH-01 ~]# export PATH=$PATH:/usr/local/mysql/bin/
[root@JSH-01 ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type `help;` or `h` for help. Type `c` to clear the current input statement.
mysql> quit;
Bye
[root@JSH-01 bin]# vi /etc/profile
[root@JSH-01 bin]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.6.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type `help;` or `h` for help. Type `c` to clear the current input statement.
mysql>
相關文章
- 編譯安裝mysql編譯MySql
- MySql 5.6.36 64位綠色版安裝MySql
- Mysql 5.7.17 編譯安裝MySql編譯
- 【MySQL安裝】Linux下安裝MySQL(預編譯)MySqlLinux編譯
- MySQL5.5.24編譯安裝MySql編譯
- MySQL 5.6.19編譯安裝MySql編譯
- 如何編譯安裝MySQL8.0編譯MySql
- 編譯安裝nginx-php-mysql編譯NginxPHPMySql
- MySQL 5.6 for REHL 6.4編譯安裝MySql編譯
- 原始碼編譯安裝MySQL 5.7.9原始碼編譯MySql
- [LAMP]Mysql-5.6.28編譯安裝LAMPMySql編譯
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- SSH免密登入+JDK安裝配置+Hadoop安裝配置JDKHadoop
- Linux編譯安裝MySQL5.6及修改字符集Linux編譯MySql
- MYSQL免安裝MySql
- MySQL 5.6原始碼編譯安裝流程MySql原始碼編譯
- 在solrais下編譯安裝MySQL(轉)SolrAI編譯MySql
- orthanc 編譯安裝mysql S3編譯MySqlS3
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- Cnetos7編譯安裝MySQL教程。編譯MySql
- centos手動編譯安裝apache、php、mysqlCentOS編譯ApachePHPMySql
- CentOS 6.4下編譯安裝MySQL 5.6.14CentOS編譯MySql
- CentOS 7 原始碼編譯安裝 Mysql 5.7CentOS原始碼編譯MySql
- MySQL 5.7.9原始碼編譯安裝說明MySql原始碼編譯
- Typescript安裝及編譯《CMD命令列方法》TypeScript編譯命令列
- 安裝mysql-5.6.36-linux-glibc2.5-x86_64.tar.gzMySqlLinux
- Atlas2.2.0編譯、安裝及使用(整合ElasticSearch,匯入Hive資料)編譯ElasticsearchHive
- 編譯安裝zabbix編譯
- apache編譯安裝Apache編譯
- 編譯安裝nmon編譯
- swoole 編譯安裝編譯
- 編譯安裝Nginx編譯Nginx
- nginx編譯安裝Nginx編譯
- 安裝編譯ffmpeg編譯
- Griffin編譯安裝編譯
- Centos 7.6 下Mysql8.0.16編譯安裝CentOSMySql編譯
- Centos6.3編譯安裝Nginx+php+MysqlCentOS編譯NginxPHPMySql