Centos 7 mysql 資料庫安裝和配置

2021-10-01 04:22:40 字數 1202 閱讀 4054

經歷無數的錯誤,終於把mysql安上了!!!!

檢視有沒有安裝過:

yum list installed mysql*

rpm -qa | grep mysql*

如果安裝了要完全解除安裝:

如何解除安裝見:

wget -i -c
yum -y install mysql57-community-release-el7-10.noarch.rpm
之後就開始安裝mysql伺服器。

yum -y install mysql-community-server
這步可能會花些時間,注意中間不要暫停。

至此mysql就安裝完成了,然後是對mysql的一些設定。

首先啟動mysql

systemctl start  mysqld.service
注意你的mysql是什麼版本!!!!

如果是5.7以下,root賬戶沒有密碼,登入mysql:

mysql -u root
設定自定義密碼:

set password for 'root'@'localhost' = password('new password');
如果是5.7及以上,有乙個暫時密碼,執行這個命令可看到:

grep "password" /var/log/mysqld.log
然後再登入:

mysql -uroot -p
設定自定義密碼:

alter user 'root'@'localhost' identified by 'new password';
把在所有資料庫的所有表的所有許可權賦值給位於所有ip位址的root使用者。

mysql> grant all privileges on *.* to root@'%'identified by 'password';
如果是新使用者而不是root,則要先新建使用者

mysql>create user 'username'@'%' identified by 'password';

centos7 mysql資料庫連不上,救急操作

方法 重置mysql密碼,無需輸入centos7系統密碼 第一步 修改配置檔案免密碼登入mysql,vim etc my.cnf 在 mysqld 最後加上如下語句 並保持退出檔案 skip grant tables 重啟mysql服務 systemctl restart mysqld.servic...

centos7 mysql資料庫安裝和配置

yum update公升級以後的系統版本為 root yl web yl cat etc redhat release centos linux release 7.1.1503 core wget rpm ivh mysql57 community release el7 11.noarch.rp...

centos7 mysql資料庫安裝和配置

yum update公升級以後的系統版本為 root localhost cat etc redhat release centos linux release 7.5.1804 core 一般網上給出的資料都是 yum install mysql yum install mysql server ...