全網最詳細的CentOS7裡安裝MySQL時出現No package mysql-server available錯誤的解決辦法(圖文詳解)

來源:互聯網
上載者:User

標籤:center   root   img   int   password   sed   code   AC   cep   

 

 

    不多說,直接上乾貨!

 

 

直接yum install mysql的話會報錯,原因在於yum安裝庫裡沒有直接可以用的安裝包,此時需要用到MariaDB了,MariaDB是MySQL社區開發的分支,也是一個增強型的替代品。

 

 

 

安裝ossec時需要使用到mysql-server,直接安裝報錯:

[[email protected] ~]# yum install mysql-serverLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileNo package mysql-server available.Error: Nothing to do

  原因是yum安裝庫裡沒有直接可以用的安裝包,這時候就需要用到MariaDB了,MariaDB是MySQL社區開發的分支,也是一個增強型的替代品。

 

 

1.安裝mariadb

yum -y  install MariaDB-server MariaDB MariaDB-develsystemctl start mariadbsystemctl enable mariadbmysql_secure_installationfirewall-cmd --permanent --add-service mysqlsystemctl restart firewalld.serviceiptables -L -n|grep 3306
[[email protected] Desktop]# yum -y install mariadb-server mariadb mariadb-devel

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 1:mariadb-server-5.5.47-1.el7_2.x86_64 already installed and latest version
Package 1:mariadb-5.5.47-1.el7_2.x86_64 already installed and latest version
Package 1:mariadb-devel-5.5.47-1.el7_2.x86_64 already installed and latest version
Nothing to do
[[email protected] Desktop]# systemctl start mariadb
[[email protected] Desktop]# systemctl start mariadb
[[email protected] Desktop]# systemctl enable mariadb
[[email protected] Desktop]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we‘ll need the current
password for the root user. If you‘ve just installed MariaDB, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] 
... Success!

Normally, root should only be allowed to connect from ‘localhost‘. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
... Success!

By default, MariaDB comes with a database named ‘test‘ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] 
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] 
... Success!

Cleaning up...

All done! If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[[email protected] Desktop]# firewall-cmd --permanent --add-service mysql
success
[[email protected] Desktop]# systemctl restart firewalld.service
[[email protected] Desktop]# iptables -L -n|grep 3306
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306 ctstate NEW
[[email protected] Desktop]#

 2.登入資料庫查看是否設定成功

mysql -uroot -pshow databases;
[[email protected] Desktop]# mysql -uroot -p

Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.47-MariaDB MariaDB Server


Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.


Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.


MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)


MariaDB [(none)]>

 mariadb相關命令:

systemctl start mariadb  #啟動MariaDBsystemctl stop mariadb  #停止MariaDBsystemctl restart mariadb  #重啟MariaDBsystemctl enable mariadb  #設定開機啟動
 

 

 

 

 

 

 

 

 

歡迎大家,加入我的公眾號:大資料躺過的坑        人工智慧躺過的坑    

同時,大家可以關注我的個人部落格

   http://www.cnblogs.com/zlslch/   和     http://www.cnblogs.com/lchzls/      http://www.cnblogs.com/sunnyDream/   

   詳情請見:http://www.cnblogs.com/zlslch/p/7473861.html

 

  人生苦短,我願分享。本公眾號將秉持活到老學到老學習無休止的交流分享開源精神,匯聚於互連網和個人學習工作的精華乾貨知識,一切來於互連網,反饋回互連網。
  目前研究領域:大資料、機器學習、深度學習、人工智慧、資料採礦、資料分析。 語言涉及:Java、Scala、Python、Shell、Linux等 。同時還涉及平常所使用的手機、電腦和互連網上的提示、問題和實用軟體。 只要你一直關注和呆在群裡,每天必須有收穫

 

      對應本平台的討論和答疑QQ群:大資料和人工智慧躺過的坑(總群)(161156071) 

 

 

 

 

 

 

 

 

 

 

 

 

 

全網最詳細的CentOS7裡安裝MySQL時出現No package mysql-server available錯誤的解決辦法(圖文詳解)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.