centos7 安装 5.6.35 MySQL Community Server
由于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%';