1.查看系统已经安装的mysql
rpm -qa | grep mysql
2.删除
rpm -e --nodeps *****
3. 下载
wget http://repo.mysql.com/mysql57-community-release-el6-10.noarch.rpm
4.安装
yum -y localinstall mysql57-community-release-el6-10.noarch.rpm
5.安装成功后在/etc/yum.repos.d/下会多出几个mysql的yum源的配置
ls -lh /etc/yum.repos.d/
6.安装mysql
yum -y install mysql-community-server
7.查看版本信息
mysql -V
8.启动mysql
service mysqld start
查看状态:
service mysqld status
加入开机启动:
chkconfig mysqld on
9.配置数据库
vi /etc/my.cnf
# 修改字符编码为utf8
character_set_server = utf8
init_connect = 'SET NAMES utf8'
# 数据库是否区分大小写,0:区分大小写,1:不区分大小写
lower_case_table_names=1
10.重启
service mysqld restart
11.查看初始密码
grep 'temporary password' /var/log/mysqld.log
12.进入数据库,修改密码
alter user 'root'@'localhost' identified by '123456';
报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决: set global validate_password_policy=LOW;
刷新权限
flush privileges;
13.查看数据库的字符集是否为配置的 utf8
show variables like "%character%";show variables like "%collation%";
14.navicat 连接mysql
报错:1130 - Host XXX is not allowed to connect to this MySQL server。
解决:进入mysql
use msyql
update user set host = '%' where user ='root';
grant all privileges on *.* to 'root'@'%' identified by '123456';
flush privileges;