centos 64 bit installation graphic tutorial mysql 5.6

First, download the official rpm package

1 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

 

Second, the installation package rpm

1 rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

Third, install mysql

1 yum -y install mysql-server 

Then check whether the installation was successful

1 rpm -qa|grep mysql

Successful installation

 

Fourth, mysql password reset

 After installation you need to reset your password, log in at this time should be given

1 mysql -u root

 

Because of permissions issues, this time using the ll command can be seen, the creator and user groups are "mysql"

The creator of the current user can modify

1 chown -R root mysql

 Modified after completion of the restart mysql service, you still can not sign in error

1 service mysqld restart

Login mysql password reset

1 mysql -u root -p
2 mysql > use mysql; 3 mysql > update user set password=password('qq1234') where user='root'; 4 mysql > exit;

Mysql restart again

1 service mysqld restart

 

Fifth, open the database port 3306

centos7 default firewall Firewall, use the following command to check the status and the port

1 firewall-cmd --state

3 firewall-cmd --list-ports

Open ports and restart the firewall

1 firewall-cmd --zone=public --add-port=3306/tcp --permanent
2 
3 firewall-cmd --reload

Which zone is scope, permanent is "permanent", do not use this parameter, reboot the port will be shut down

 

Sixth, remote login database

After a single open port also needs to be open sign-in permission being given otherwise use remote login software mysql, you are prompted to be rejected

在服务器端登入mysql之后输入以下命令,(任何机器都能使用root用户身份登陆远程数据库)

1 use mysql;
2 update user set host ='%' where user ='root' and host='localhost';

 

输入完最后一句可能会报错 ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY',(host里已经有%这个值)不用管,刷新数据库权限

1 flush privileges;

 

重新连接,成功登入

 

 

 七、关于chown和mysql远程登入

 

1、chown(更改文件拥有者以及用户组):chown 用户名:组名 文件或目录

只输入一个参数为修改用户,不修改用户组

-R:递归授权

 

例:chown mysql:mysql tomcat8

 

2、mysql的另一种授权方式

用户user使用password从任何主机连接到mysql

GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

 

用户user使用password从指定主机连接到mysql

GRANT ALL PRIVILEGES ON *.* TO 'user'@'192.168.0.1' IDENTIFIED BY 'password' WITH GRANT OPTION;

 

最终使用

flush privileges;

刷新权限即可

Guess you like

Origin www.cnblogs.com/pandawan/p/11058715.html