CentOS 7 版本將MySQL數(shù)據(jù)庫軟件從默認的程序列表中移除,用mariadb代替了。所以要安裝mysql有兩種方法,一種是直接安裝mariadb,另一種是從官網(wǎng)下載mysql手動安裝
這里只介紹第二種方法。
一、系統(tǒng)環(huán)境
# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
二、官網(wǎng)下載安裝mysql-server
# 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
安裝成功后重啟mysql服務。
# service mysqld restart
初次安裝mysql,root賬戶沒有密碼。
# mysql -u root
設置密碼
mysql> set password for 'root'@'localhost' =password('password');
三、配置mysql
- 編碼
mysql配置文件為/etc/my.cnf
[mysql]
default-character-set =utf8
- 遠程連接
create user 'username'@'%' identified by 'password';
grant all privileges on *.* to root@'%'identified by 'password';