查看安裝以及卸載
# 查看
rpm -qa | grep mysql
# 卸載
yum -y remove mysql-libs-5.1.66-2.el6_3.x86_64
1.centos7需要先卸載mariadb
查看命令rpm -qa | grep mariadb
安裝包資源地址
mysql下載地址:https://dev.mysql.com/downloads/mysql/
# 下載資源名稱
mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
解壓資源
tar -xvf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar
獲取rpm包
mysql-community-common-5.7.19-1.el6.x86_64.rpm
mysql-community-client-5.7.19-1.el6.x86_64.rpm
mysql-community-server-5.7.19-1.el6.x86_64.rpm
mysql-community-libs-5.7.19-1.el6.x86_64.rpm
安裝
# 安裝順序
# common --> libs --> clients --> server
# 安裝命令
rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm mysql-community-libs-5.7.19-1.el6.x86_64.rpm mysql-community-client-5.7.19-1.el6.x86_64.rpm mysql-community-server-5.7.19-1.el6.x86_64.rpm
可能需要依賴包libaio
安裝命令yum -y install libaio
初始化
mysqld --initialize --user=mysql
啟動
登錄
# 查看初始密碼
cat /var/logs/mysql.log
#或者
grep 'password' /var/logs/mysql.log -n -B 5
# 登陸
mysql -uroot -p'123456'
# 修改初始密碼
set PASSWORD=PASSWORD('密碼');
授權(quán)遠(yuǎn)程鏈接
### 授權(quán)192.168.0.1可以遠(yuǎn)程鏈接*[所有數(shù)據(jù)庫].*[所有表] 賬號:root 密碼123456
grant all privileges on *.* to 'root'@'192.168.0.1' identified by '123456';
### 授權(quán)所有ip
grant all privileges on *.* to 'root'@'%' identified by '123456';
### 以上*.*表示[數(shù)據(jù)庫].[表]
### 使授權(quán)立刻生效
flush privileges;
您可能感興趣的文章:- MySQL數(shù)據(jù)庫遷移快速導(dǎo)出導(dǎo)入大量數(shù)據(jù)
- shell腳本操作mysql數(shù)據(jù)庫刪除重復(fù)的數(shù)據(jù)
- MySQL數(shù)據(jù)庫列的增刪改實現(xiàn)方法
- MySQL實現(xiàn)類似Oracle序列的方案
- mysql實現(xiàn)sequence功能的代碼
- Can''t connect to local MySQL through socket ''/tmp/mysql.sock''解決方法
- Mysql常用函數(shù)大全(分類匯總講解)
- 利用MySQL主從配置實現(xiàn)讀寫分離減輕數(shù)據(jù)庫壓力
- mysql+spring+mybatis實現(xiàn)數(shù)據(jù)庫讀寫分離的代碼配置
- MySQL中字段類型char、varchar和text的區(qū)別