CentOS 7 安裝Mariadb 及詳解

來源:互聯網
上載者:User
1. CentOS 7.0 版本資訊查看
#cat /etc/redhat-release
2. 安裝Mariadb
#yum -y install mariadb*
3.串連Mariadb
報錯: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
4.解決串連不上的問題
#systemctl start mariadb.service
#systemctl enable mariadb.service
# mysql
5.修改root密碼
以root身份在終端登陸,必須
輸入 mysqladmin -u root -p password root(這個root是密碼)
後面的 root 是要設定的密碼
斷行符號後出現 Enter password 
輸入就密碼,如果沒有,直接斷行符號
6.建立使用者
//建立使用者
mysql> insert into mysql.user(Host,User,Password) values("localhost","admin",password("admin"));
//重新整理系統許可權表
mysql>flush privileges;
這樣就建立了一個名為:admin  密碼為:admin  的使用者。
7.建立資料庫(在root許可權下)
create database mydb;
//授權admin使用者擁有mydb資料庫的所有許可權。
>grant all privileges on mydb.* to admin@localhost identified by 'admin';
//重新整理系統許可權表
mysql>flush privileges;
8.刪除使用者。
@>mysql -u root -p
@>密碼
mysql>DELETE FROM user WHERE User="admin" and Host="localhost";
mysql>flush privileges;
//刪除使用者的資料庫
mysql>drop database mydb;
9.修改指定使用者密碼。
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password('新密碼') where User="admin" and Host="localhost";

mysql>flush privileges; 10.Navicat 串連mysql失敗: Host '*' is not allowed to connect to this MariaDB server
問題描述:Navicat 為管理方便,串連Linux 中mysql失敗,如下如下錯誤:Host '*' is not allowed to connect to this MariaDB server
//允許使用者testuser從ip為222.129.1.1的主機串連到mysql伺服器,並使用testpassword作為密碼   MariaDB [(none)]> grant all privileges on *.* to 'testuser'@'222.129.1.1' identified by 'testpassword' with grant option;     (若是允許所有ip:GRANT ALL PRIVILEGES ON *.* TO ‘testuser’@'%’ IDENTIFIED BY ‘testpassword’ WITH GRANT OPTION;)   MariaDB [(none)]> flush privileges;   //重新整理許可權緩衝   MariaDB [(none)]> show privileges;   MariaDB [(none)]> show grants for  'testuser'@'222.129.1.1'    11.刪除已有資料庫

使用rpm -qa | grep mariadb搜尋 MariaDB 現有的包:

如果存在,使用rpm -e --nodeps mariadb-*全部刪除: 刪除mysql所有包:

如果存在,使用yum remove mysql mysql-server mysql-libs compat-mysql51全部刪除;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.