Centos安装MYSQL

官网下载安装mysql-server mysql

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm web

# rpm -ivh mysql-community-release-el7-5.noarch.rpm sql

# yum install mysql-community-server 数据库

安装成功后重启mysql服务。 vim

# service mysqld restart tcp

初次安装mysql,root帐户没有密码。 ide

clip_image001

[root@yl-web yl]# mysql -u root 编码

Welcome to the MySQL monitor. Commands end with ; or \g. rest

…. orm

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.01 sec)

mysql>

设置密码

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

Query OK, 0 rows affected (0.00 sec)

mysql>

配置mysql

1、编码

mysql配置文件为/etc/my.cnf

最后加上编码配置

[mysql]

default-character-set =utf8

这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。

clip_image002

2、远程链接设置

把在全部数据库的全部表的全部权限赋值给位于全部IP地址的root用户。

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

若是是新用户而不是root,则要先新建用户

mysql>create user 'username'@'%' identified by 'password';

此时就能够进行远程链接了。

3、防火墙设置

开放防火墙:

service firewalld stop 或者 systemctl stop firewalld.service

而后安装iptables-services:

yum install iptables-services

编辑配置文件:

vim /etc/sysconfig/iptables

在commit以前加一行

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306-j ACCEPT

重启服务

service iptables restart

相关文章
相关标签/搜索