安装mysql:
查看有没有安装过:
yum list installed mysql*
rpm -qa | grep mysql*
查看有没有安装包:
yum list mysql*
安装mysql客户端:
yum install mysql
安装mysql 服务器端:
yum install mysql-server
yum install mysql-devel
如果必须要安装MySQL,首先必须添加mysql社区repo通过输入命令:
sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm,
最后使用像安装MySQL的常规方法一样安装mysql: yum install mysql mysql-server mysql-libs mysql-server
允许远程连接配置:
use mysql
mysql> select host, user from user;
将相应用户数据表中的host字段改成'%';
update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理会
flush privileges;
为用户创建指定数据库与权限:
create user 'test'@'localhost' identified by '123456';
create user 'test'@'%' identified by '123456';
flush privileges;
create database mwx DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';
grant all privileges on `testdb`.* to 'test'@'localhost' identified by '123456';
flush privileges;
启动:service mysqld start
停止:service mysqld stop
重启:service mysqld restart
修改密码:use mysql;
UPDATE user SET password=PASSWORD(‘123456’) WHERE user=‘root’;
查看端口 netstat -apn | grep mysql
netstat -antp|grep mysqld| grep LISTEN