安裝環境: CentOS Linux release 7.3.1611 (Core)html
從網上找到下面命令:mysql
#yum install mysql-server #yum install mysql-devel #yum install mysql
安裝mysql-server會出現失敗,以下輸出web
[root@knl ~]# yum install mysql-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.btte.net * updates: mirrors.btte.net No package mysql-server available
查資料發現是CentOS7版本將MySQL數據庫軟件從默認的程序列表中移除,用mariadb代替了。:(sql
有兩種解決辦法:數據庫
MariaDB數據庫管理系統是MySQL的一個分支,主要由開源社區在維護,採用GPL受權許可。開發這個分支的緣由之一是:甲骨文公司收購了MySQL後,有將MySQL閉源的潛在風險,所以社區採用分支的方式來避開這個風險。MariaDB的目的是徹底兼容MySQL,包括API和命令行,使之能輕鬆成爲MySQL的代替品。ide
安裝mariadb,大小59 M。this
[root@yl-web yl]# yum install mariadb-server mariadb
安裝過程編碼
========================================================================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================================================================= Installing: mariadb x86_64 1:5.5.52-1.el7 base 8.7 M mariadb-server x86_64 1:5.5.52-1.el7 base 11 M Installing for dependencies: perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k perl-DBD-MySQL x86_64 4.023-5.el7 base 140 k perl-DBI x86_64 1.627-4.el7 base 802 k perl-IO-Compress noarch 2.061-2.el7 base 260 k perl-Net-Daemon noarch 0.48-5.el7 base 51 k perl-PlRPC noarch 0.2020-14.el7 base 36 k Transaction Summary ========================================================================================================================================================================================================= Install 2 Packages (+7 Dependent packages) Total download size: 21 M Installed size: 107 M Is this ok [y/d/N]: y
上面要輸出y,而後回車。.net
mariadb數據庫的相關命令是:命令行
- systemctl start mariadb #啓動MariaDB - systemctl stop mariadb #中止MariaDB - systemctl restart mariadb #重啓MariaDB - systemctl enable mariadb #設置開機啓動
記得啓動MySQL數據庫服務。
首先下載:
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm yum install mysql-community-server
(最後一步我沒有成功,多是yum源有區別)
安裝成功後重啓mysql服務。
# service mysqld restart
初次安裝mysql,root帳戶沒有密碼。直接經過mysql -uroot
進入。
mysql配置文件爲/etc/my.cnf
最後加上編碼配置
[mysql] default-character-set=utf8
這裏的字符編碼必須和/usr/share/mysql/charsets/Index.xml中一致。
把在全部數據庫的全部表的全部權限賦值給位於全部IP地址的root用戶。
mysql> grant all privileges on *.* to root@'%'identified by 'password'; mysql> mysql> flush privileges;
若是是新用戶而不是root,則要先新建用戶
mysql>create user 'username'@'%' identified by 'password';
此時就能夠進行遠程鏈接了。
參考: