人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

CentOS安裝MySQL5.5的完整步驟

發(fā)布日期:2021-12-08 08:09 | 文章來(lái)源:腳本之家

一 、安裝前準(zhǔn)備、安裝包下載

1 準(zhǔn)備安裝

由于CentOS7自帶的是 Mariadb, 所以先來(lái)刪除他吧…

查找版本

# rpm -qa|grep mariadb

執(zhí)行命令后會(huì)出現(xiàn)類似 MariaDB-server-5.5.49-1.el7.centos.x86_64 之類的鬼…記住名字就行了…

刪除

# rpm -e --nodeps 上面查出來(lái)的文件名

刪除配置文件

# rm /etc/my.cnf

到這里就OK了…現(xiàn)在我們開始安裝mysql

2 下載安裝包

下載地址 https://downloads.mysql.com/archives/community/

二、開始安裝

1 將tar安裝包上傳到CentOS并解壓

上傳

[root@bogon /]# cd /tmp
[root@bogon tmp]# rz              #然后選擇安裝包上傳到CentOS
[root@bogon tmp]# ll
-rw-r--r--.  1 root root 198993245 11月  6 12:35 mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

解壓

[root@bogon tmp]# tar -zxvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
[root@bogon tmp]# ll
drwxr-xr-x. 13 root root       213 11月  6 12:41 mysql-5.5.62-linux-glibc2.12-x86_64
-rw-r--r--.  1 root root 198993245 11月  6 12:35 mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

2 移動(dòng)到/usr/local目錄下并改名

[root@bogon tmp]# mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/
[root@bogon tmp]# cd /usr/local/
[root@bogon local]# ll
總用量 0
drwxr-xr-x.  2 root root   6 5月  11 2019 bin
drwxr-xr-x.  2 root root   6 5月  11 2019 etc
drwxr-xr-x.  2 root root   6 5月  11 2019 games
drwxr-xr-x.  2 root root   6 5月  11 2019 include
drwxr-xr-x.  2 root root   6 5月  11 2019 lib
drwxr-xr-x.  2 root root   6 5月  11 2019 lib64
drwxr-xr-x.  2 root root   6 5月  11 2019 libexec
drwxr-xr-x. 13 root root 213 11月  6 12:41 mysql-5.5.62-linux-glibc2.12-x86_64
drwxr-xr-x.  2 root root   6 5月  11 2019 sbin
drwxr-xr-x.  5 root root  49 8月  23 10:42 share
drwxr-xr-x.  2 root root   6 5月  11 2019 src
[root@bogon local]# mv mysql-5.5.62-linux-glibc2.12-x86_64 mysql-5.5.60
[root@bogon local]# ll
總用量 0
drwxr-xr-x.  2 root root   6 5月  11 2019 bin
drwxr-xr-x.  2 root root   6 5月  11 2019 etc
drwxr-xr-x.  2 root root   6 5月  11 2019 games
drwxr-xr-x.  2 root root   6 5月  11 2019 include
drwxr-xr-x.  2 root root   6 5月  11 2019 lib
drwxr-xr-x.  2 root root   6 5月  11 2019 lib64
drwxr-xr-x.  2 root root   6 5月  11 2019 libexec
drwxr-xr-x. 13 root root 213 11月  6 12:41 mysql-5.5.60
drwxr-xr-x.  2 root root   6 5月  11 2019 sbin
drwxr-xr-x.  5 root root  49 8月  23 10:42 share
drwxr-xr-x.  2 root root   6 5月  11 2019 src

3 增加MySQL配置文件

[root@bogon local]# vi /etc/my.cnf

將一下內(nèi)容復(fù)制到新文件中

[mysql]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8 
socket=/var/lib/mysql/mysql.sock
[mysqld]
skip-name-resolve
#設(shè)置3306端口
port = 3306 
socket=/var/lib/mysql/mysql.sock
# 設(shè)置mysql的安裝目錄, 這里的目錄一定要是你解壓后并且改了名的目錄喲..
basedir=/usr/local/mysql-5.5.60
# 設(shè)置mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)的存放目錄, 這里的目錄一定要是你解壓后并且改了名的目錄喲..
datadir=/usr/local/mysql-5.5.60/data
# 允許最大連接數(shù)
max_connections=200
# 服務(wù)端使用的字符集默認(rèn)為8比特編碼的latin1字符集
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M

4 再配置并安裝

配置命令:

# cd /usr/local/mysql-5.5.60
# groupadd mysql
# useradd -g mysql mysql
# chown -R mysql:mysql ./

安裝命令:

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.60/ --datadir=/usr/local/mysql-5.5.60/data/

演示:

[root@bogon local]# cd mysql-5.5.60/
[root@bogon mysql-5.5.60]# 
[root@bogon mysql-5.5.60]# groupadd mysql
groupadd:“mysql”組已存在
[root@bogon mysql-5.5.60]# useradd -g mysql mysql
useradd:用戶“mysql”已存在
[root@bogon mysql-5.5.60]# chown -R mysql:mysql ./
[root@bogon mysql-5.5.60]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.60/ --datadir=/usr/local/mysql-5.5.60/data/
Installing MySQL system tables...
....
....
Please report any problems at http://bugs.mysql.com/
[root@bogon mysql-5.5.60]# chown -R mysql:mysql data
[root@bogon mysql-5.5.60]# chown 777 /etc/my.cnf 
[root@bogon mysql-5.5.60]# ll
總用量 56
drwxr-xr-x.  2 mysql mysql  4096 11月  6 12:41 bin
-rw-r--r--.  1 mysql mysql 17987 8月  29 2018 COPYING
drwxr-xr-x.  5 mysql mysql    57 11月  6 12:48 data
drwxr-xr-x.  2 mysql mysql    55 11月  6 12:41 docs
drwxr-xr-x.  3 mysql mysql  4096 11月  6 12:41 include
-rw-r--r--.  1 mysql mysql   301 8月  29 2018 INSTALL-BINARY
drwxr-xr-x.  3 mysql mysql  4096 11月  6 12:41 lib
drwxr-xr-x.  4 mysql mysql    30 11月  6 12:41 man
drwxr-xr-x. 10 mysql mysql  4096 11月  6 12:41 mysql-test
-rw-r--r--.  1 mysql mysql  2496 8月  29 2018 README
drwxr-xr-x.  2 mysql mysql    30 11月  6 12:41 scripts
drwxr-xr-x. 27 mysql mysql  4096 11月  6 12:41 share
drwxr-xr-x.  4 mysql mysql  4096 11月  6 12:41 sql-bench
drwxr-xr-x.  2 mysql mysql  4096 11月  6 12:41 support-files
[root@bogon mysql-5.5.60]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@bogon mysql-5.5.60]# chmod +x /etc/rc.d/init.d/mysqld
[root@bogon mysql-5.5.60]# chkconfig --add mysqld
[root@bogon mysql-5.5.60]# chkconfig --list mysqld
注:該輸出結(jié)果只顯示 SysV 服務(wù),并不包含
原生 systemd 服務(wù)。SysV 配置數(shù)據(jù)
可能被原生 systemd 配置覆蓋。 
      要列出 systemd 服務(wù),請(qǐng)執(zhí)行 'systemctl list-unit-files'。
      查看在具體 target 啟用的服務(wù)請(qǐng)執(zhí)行
      'systemctl list-dependencies [target]'。
mysqld         	0:關(guān)	1:關(guān)	2:開	3:開	4:開	5:開	6:關(guān)

三、配置并啟動(dòng)服務(wù)

1 配置命令(在MySQL目錄下)

# chown -R mysql:mysql data
# chown 777 /etc.my.cnf
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list mysqld

chmod 和 chown的區(qū)別

chown 修改文件和文件夾的用戶和用戶組屬性 
	(1)要修改文件hh.c的所有者.修改為sakia的這個(gè)用戶所有 
		chown sakia hh.c      #這樣就把hh.c的用戶訪問(wèn)權(quán)限應(yīng)用到sakia作為所有者 
	(2)將目錄 /tmp/sco 這個(gè)目錄的所有者和組改為sakia和組net 
		chown -R sakia:net /tmp/sco 
		
chmod 修改文件和文件夾讀寫執(zhí)行屬性 
	(1)把hh.c文件修改為可寫可讀可執(zhí)行 
		chmod 777 hh.c 
	(2)要修改某目錄下所有的文件屬性為可寫可讀可執(zhí)行 
		chmod 777 *.*    #把文件夾名稱與后綴名用*來(lái)代替就可以了。 
	(3)同理若是要修改所有htm文件的屬性 
		chmod 777 *.htm 
	(4)把目錄 /tmp/sco修改為可寫可讀可執(zhí)行 
		chmod 777 /tmp/sco 
	(5)要修改某目錄下所有的文件夾屬性為可寫可讀可執(zhí)行 
		chmod 777 *   #把文件夾名稱用*來(lái)代替就可以了 
    (6)要修改/tmp/sco下所有的文件和文件夾及其子文件夾屬性為可寫可讀可執(zhí)行 
		chmod -R 777 /tmp/sco 
##
可寫 w=4 
可讀 r=2 
可執(zhí)行 x=1 
777就是擁有全權(quán)限,根據(jù)需要可以自由組合用戶和組的
##

2 啟動(dòng)服務(wù)命

[root@bogon mysql-5.5.60]# service mysqld start

3 *報(bào)錯(cuò)及解決方法

一旦報(bào)錯(cuò)

[root@bogon mysql-5.5.60]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql-5.5.60/data/bogon.err'.
201106 12:50:02 mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
ERROR! The server quit without updating PID file (/usr/local/mysql-5.5.60/data/bogon.pid).

解決方法

隨即執(zhí)行命令:cat  /usr/local/mysql/data/iZ2ze8hspx8qsmxx7b1i9sZ.err查看錯(cuò)誤原因
error內(nèi)容如下:
[ERROR] Can't start server : Bind on unix socket: Permission denied
[ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
結(jié)合先前寫入配置/etc/my.cnf:

由上不難理解——

第一:

mysqld_safe Directory ‘/var/lib/mysql' for UNIX socket file don't exists.
“var/lib/mysql”目錄不存在,首要先創(chuàng)建:

mkdir /var/lib/mysql
第二:

Mysql客戶端和服務(wù)器端是通過(guò)初始化mysql.sock 文件來(lái)進(jìn)行通信,所以服務(wù)器在啟動(dòng)時(shí)需要寫入該文件,因此該文件所存放的目錄必須雙方都

具有訪問(wèn)權(quán)限。而異常日志中表示:

[ERROR] Can't start server : Bind on unix socket: Permission denied

所以,MySQL服務(wù)不具備目錄 /var/lib/mysql 的寫入權(quán)限,無(wú)法生成mysql.sock文件,自然服務(wù)啟動(dòng)時(shí)無(wú)法找到該文件。

給目錄 /var/lib/mysql 付予寫入權(quán)限或者最大權(quán)限—chmod 777 /var/lib/mysql

[root@bogon lib]# mkdir mysql
[root@bogon lib]# chmod 777 -R mysql/

最終:

[root@bogon lib]# service mysql start
Starting MySQL... SUCCESS! 

4 配置環(huán)境變量

配置PATH

# vi ~/.bash_profile

在文件最后面加入以下內(nèi)容,并使用:wq保存

export PATH=$PATH:/usr/local/mysql-5.5.60/bin

刷新PATH

# source ~/.bash_profile

四、登錄并配置遠(yuǎn)程登錄

1 首次登錄MySQL

[root@bogon lib]# mysql -uroot -p

2 *報(bào)錯(cuò)及解決方法

[root@bogon lib]# mysql -uroot -p
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

系統(tǒng)是redhad8,binary方式安裝完mysql之后,mysql命令登錄不成功,報(bào)錯(cuò):mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory。按照百度的方法都不成功,應(yīng)該和系統(tǒng)版本有關(guān),后來(lái)自己想到一個(gè)方法:yum install libncurses*,完美解決問(wèn)題。

解決:

[root@bogon lib]# yum -y install libncurses*
[root@bogon lib]# mysql -uroot -p  
Enter password:               #直接回車登錄
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>

3 修改root密碼

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password('需要設(shè)置的密碼') where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> update user set password=password('12345') where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4 設(shè)置遠(yuǎn)程登錄

mysql> grant all privileges on *.* to 'root'@'%' identified by '12345' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

如果遠(yuǎn)程無(wú)法登錄則關(guān)閉防火墻

[root@bogon lib]# systemctl stop firewalld.service

總結(jié)

到此這篇關(guān)于CentOS安裝MySQL5.5的文章就介紹到這了,更多相關(guān)CentOS安裝MySQL5.5內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問(wèn)服務(wù)

1對(duì)1客戶咨詢顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部