CentOS 7下rpm安装MySQL 5.6.36

本地安装了mysql5.7, 但和springboot整合jpa时会出现 hibernateException, 不知道为什么, 换个mysql5.6版本的mysql,  源码安装, cmake一直过不去, 后来改成rpm安装

1, 获取mysql5.6

ftp://ftp.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.6/

下载: 

其中  el6标识 centos 6, el7 标识centos 7

2, 安装

rpm -ivh MySQL-*

3, 启动

systemctl start mysql

4, 查看初始密码

cat /root/.mysql_secret

5, 更改密码

mysql -uroot -pKAKt5JmEjm6B8omV
SET PASSWORD = PASSWORD('root');

 6, 远程登陆设置

mysql> user mysql;
mysql> select host, user, password from user;
mysql> update user set password=password('root') where user='root';
mysql> update user set host='%' where user='root' and host='localhost';

授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '这里是你的密码' WITH GRANT

7, 设置开机启动

[root@localhost ~]# chkconfig mysql on
[root@localhost ~]# chkconfig --list | grep mysql

8, MySQL的默认安装位置

/var/lib/mysql/               #数据库目录
/usr/share/mysql              #配置文件目录
/usr/bin                     #相关命令目录
/etc/init.d/mysql              #启动脚本

9, 修改默认字符集等

vim /etc/my.cnf

[client] 
password        = root
port            = 3306 
default -character- set =utf8 
[mysqld] 
port            = 3306 
character_set_server=utf8 
character_set_client=utf8 
collation-server=utf8_general_ci 
#(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) 
lower_case_table_names=1 
#(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) 
max_connections=1000 
[mysql] 
default -character- set = utf8 

10, 查看字符集

show variables like '%collation%';  
show variables like '%char%'

猜你喜欢

转载自www.linuxidc.com/Linux/2017-07/145758.htm
今日推荐