Centos 安装 MySQL

前言

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件 [ 百度百科 ]

开始

1 .去官网下载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-server

2 .安装成功启动mysql服务

service mysqld restart

3 .设置root密码

 mysql -u root
 mysql -> set password for 'root'@'localhost' =password('123456');

4 .开启远程连接,把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户

 mysql -> grant all privileges on *.* to root@'%'identified by '123456';

5 .重启mysql服务

service mysqld restart

6 .开启mysql防火墙和端口

错误 -1:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
解决方法:

mysql -u root -p

错误 -2:1130-Host ‘192.168.0.118’ is not allowed to connect to this MySQL server
解决方法:

  mysql -u root -p  
  123456
  mysql ->use mysql;
  mysql ->select 'host' from user where user='root';
  mysql ->update user set host = '%' where user ='root';
  mysql ->flush privileges;
  mysql ->select 'host'   from user where user='root';

结束

附上成功图片一张:
成功图片

原文地址:https://www.cnblogs.com/alvis/p/9438846.html