由於Centos7版本從默認程序列表中移除了MySql,需要從官網下載安裝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-serve
啟動MySQl服務:
# service mysqld start
登錄進Mysql(剛開始進入時是沒有密碼的)
#mysql -uroot
設置登錄密碼
mysql> set password for 'root'@'localhost' = password('yourPassword');
添加遠程登錄用戶
mysql> grant all privileges on *.* to 'root'@'%' identified by 'yourPassword';
遠程登錄
#mysql -uroot -h ip(遠程的ip地址) -p
Mysql中文編碼設置(設置為utf8):
1.關閉 mysql服務,打開mysql配置文件/etc/my.cnf
#service mysqld stop
#vim /etc/my.cnf
2.修改/etc/my.cnf
在[mysqld]標簽下添加
character_set_server = utf8
在[mysqld_safe]標簽下添加
default-character-set = utf8
添加[mysql]標簽並在該標簽下添加
default-character-set = utf8
3.重啟mysql服務
#service mysqld restart
4.登錄進mysql,查看mysql的編碼
#show variables like '%character%';