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安裝】Linux下安裝MySQL(預編譯)MySqlLinux編譯
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- 如何編譯安裝MySQL8.0編譯MySql
- 編譯安裝nginx-php-mysql編譯NginxPHPMySql
- SSH免密登入+JDK安裝配置+Hadoop安裝配置JDKHadoop
- orthanc 編譯安裝mysql S3編譯MySqlS3
- Cnetos7編譯安裝MySQL教程。編譯MySql
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- 安裝mysql-5.6.36-linux-glibc2.5-x86_64.tar.gzMySqlLinux
- MYSQL免安裝MySql
- MAC M3 編譯安裝mysql 5.7.44Mac編譯MySql
- Centos 7.6 下Mysql8.0.16編譯安裝CentOSMySql編譯
- Typescript安裝及編譯《CMD命令列方法》TypeScript編譯命令列
- Ubuntu 18.04系統編譯安裝MySQL 5.7教程。Ubuntu編譯MySql
- windows 7 vs 2013編譯與安裝MySQL 5.7Windows編譯MySql
- LNMP架構編譯安裝(Linux、Nginx、Mysql、PHP)LNMP架構編譯LinuxNginxMySqlPHP
- Atlas2.2.0編譯、安裝及使用(整合ElasticSearch,匯入Hive資料)編譯ElasticsearchHive
- 安裝編譯ffmpeg編譯
- 編譯安裝nmon編譯
- Griffin編譯安裝編譯
- apache編譯安裝Apache編譯
- swoole 編譯安裝編譯
- 編譯安裝zabbix編譯
- Mysql安裝和遠端登入--Centos7MySqlCentOS
- ffmpeg安裝之linux編譯安裝Linux編譯
- Linux系統下自行編譯安裝MySQL及基礎配置全過程解析Linux編譯MySql
- Ubuntu 20.04系統編譯安裝MySQL5.7教程。Ubuntu編譯MySql
- Centos6.4編譯安裝mysql 8.0.0 詳細教程CentOS編譯MySql
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- 在VMware已安裝的CentOS7.9上編譯安裝mysql5.6CentOS編譯MySql
- Linux 編譯安裝 PythonLinux編譯Python
- Shell編譯安裝nginx編譯Nginx
- Linux編譯安裝NginxLinux編譯Nginx
- centos PHP 編譯安裝CentOSPHP編譯
- httpd編譯安裝phphttpd編譯PHP
- Debian11系統編譯安裝MySQL5.7教程。編譯MySql
- CentOS6.7下使用cmake編譯安裝MySQL5.5.32CentOS編譯MySql