1.遠程連接云服務(wù)器
2.創(chuàng)建一個存放mysql安裝包的文件夾
cd /usr/local/tools
mkdir -p mysql
cd mysql
3.查看是否已經(jīng)安裝mysql
rpm -qa | grep mysql? ?或? ?yum list installed | grep mysql
4.如果已安裝則刪除 MySQL 及其依賴的包:
yum -y remove mysql-libs.x86_64
5.下載 mysql57-community-release-el7-8.noarch.rpm 的 YUM 源:
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
6.安裝 mysql57-community-release-el7-8.noarch.rpm:
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
7.安裝 MySQL:
yum install mysql-server
一路 Y 下去即可
8.重置密碼
vim /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存并且退出vi色徘。
9.重新啟動mysqld
啟動 MySQL 服務(wù):
service mysqld start
關(guān)閉 MySQL 服務(wù):
service mysqld stop
重啟 MySQL 服務(wù):
service mysqld restart
查看 MySQL 的狀態(tài):
service mysqld status
登錄并修改MySQL的root密碼
# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3 to server version: 3.23.56
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql> USE mysql ;
Database changed
mysql> update mysql.user set authentication_string=password('你的新密碼') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit;
將MySQL的登錄設(shè)置修改回來
# vim /etc/my.cnf
將剛才在[mysqld]的段中加上的skip-grant-tables刪除
保存并且退出vim
重新啟動mysqld
# service mysqld restart
三:解決遠程連接mysql錯誤1130
遠程連接Mysql服務(wù)器的數(shù)據(jù)庫道媚,錯誤代碼是1130,ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server
猜想是無法給遠程連接的用戶權(quán)限問題捻悯。
這樣子操作mysql庫,即可解決旦签。
在本機登入mysql后拾稳,更改 “mysql” 數(shù)據(jù)庫里的 “user” 表里的 “host” 項,從”localhost”改稱'%'即可
命令:
mysql -u root -p
mysql;use mysql;
mysql;select 'host' from user where user='root';
mysql;update user set host = '%' where user ='root';
mysql;flush privileges;
mysql;select 'host' from user where user='root';