安裝Redis
yum install epel-release
yum install redis
yum方式安裝的Redis的配置文件位置
vim /etc/redis.conf
設(shè)置redis為開機自動啟動
chkconfig redis on
常常修改的地方有
1. 修改配置文件捷沸,監(jiān)聽所有的IP地址 # bind 127.0.01
2. 配置密碼 #requirepass foobared 打開注釋吃溅,設(shè)置密碼即可
redis命令操作
啟動 service redis restart
停止 service redis stop
重啟 service redis restart
查看狀態(tài) service redis status
進入本機redis
無密碼形式 redis-cli
密碼形式 redis-cli -h 127.0.0.1 -p 6379 -a myPassword
為什么選擇5.7
因為8.0版本和5.6版本安裝和使用太坑了
下載mysql源安裝包
# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安裝mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
檢查mysql源是否安裝成功
# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 74
mysql-tools-community/x86_64 MySQL Tools Community 74
mysql57-community/x86_64 MySQL 5.7 Community Server 307
安裝時可能會出現(xiàn)類似以下的錯誤:
Error downloading packages:
mysql-community-client-5.7.27-1.el7.x86_64: [Errno 256] No more mirrors to try.
mysql-community-common-5.7.27-1.el7.x86_64: [Errno 256] No more mirrors to try.
解決方案如下:
1. 清理軟件源 yum clean all
2. 建立源數(shù)據(jù)緩存 yum makecache
安裝MySQL
yum install mysql-community-server
靜靜等待下載和安裝即可嗦明。若下載速度較慢邪锌,如圖、則可以ctrl+c強制關(guān)掉下載過程或杠,然后重新執(zhí)行安裝命令即可,比較好使。我認為正常速度500-800K
查看安裝了哪些包
# rpm -qa | grep mysql
mysql57-community-release-el7-8.noarch
mysql-community-common-5.7.30-1.el7.x86_64
mysql-community-client-5.7.30-1.el7.x86_64
mysql-community-libs-5.7.30-1.el7.x86_64
mysql-community-libs-compat-5.7.30-1.el7.x86_64
mysql-community-server-5.7.30-1.el7.x86_64
啟動MySQL服務(wù)
service mysqld start
service mysqld status
查看默認隨機密碼悍赢,登錄,并且修改
# grep 'temporary password' /var/log/mysqld.log
# mysql -uroot -p
# ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
# flush privileges;
若通過grep 'temporary password' /var/log/mysqld.log 命令無法輸出默認密碼則需要
1.刪除原來安裝過的mysql殘留的數(shù)據(jù)(這一步非常重要货徙,問題就出在這)
rm -rf /var/lib/mysql
2.重啟mysqld服務(wù)
service mysqld restart
3.再去找臨時密碼
grep 'temporary password' /var/log/mysqld.log
遠程登錄
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Abcd1234!' WITH GRANT OPTION;
# flush privileges;
默認mysql相關(guān)文件地址
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服務(wù)啟動腳本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
修改mysql默認編碼為utf8
vim /etc/my.cnf
在[mysqld]下面增加
character_set_server=utf8
重啟MySQL
systemctl restart mysqld
然后進入到mysql查看
show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
卸載mysql
service mysqld stop
rpm -qa | grep -i mysql
mysql-community-server-8.0.13-1.el7.x86_64
mysql-community-libs-8.0.13-1.el7.x86_64
mysql-community-common-8.0.13-1.el7.x86_64
mysql-community-client-8.0.13-1.el7.x86_64
rpm -ev mysql-community-server-8.0.13-1.el7.x86_64 --nodeps
rpm -ev mysql-community-libs-8.0.13-1.el7.x86_64 --nodeps
rpm -ev mysql-community-common-8.0.13-1.el7.x86_64 --nodeps
rpm -ev mysql-community-client-8.0.13-1.el7.x86_64 --nodeps
find / -name mysql
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /etc/my.cnf