首页  »   MySQL

mysql5.7 装配

网友分享于:2018-04-18  浏览:0次
mysql5.7 安装

官方地址:

https://dev.mysql.com/downloads/mysql/

 

安装mysql源

#yum localinstall mysql57-community-release-el7-{version-number}.noarch.rpm

$ yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

 

安装mysql

$ yum install mysql-community-server

 

安装mysql的开发包

$ yum install mysql-community-devel

 

查看mysql状态

systemctl status mysqld.service

● mysqld.service - MySQL Server

   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

   Active: inactive (dead)

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

 

启动MySQL

$ systemctl start mysqld.service

● mysqld.service - MySQL Server

   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

   Active: active (running) since Mon 2018-04-16 01:47:59 UTC; 5s ago

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

  Process: 17327 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)

  Process: 17256 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

 Main PID: 17329 (mysqld)

   CGroup: /docker/1391c87e0974ca70633404d8eb5ef54f6d2e443d84db634a224cb67fb26cc83d/system.slice/mysqld.service

           └─17329 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/my...

           ‣ 17329 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/my...

 

Apr 16 01:47:56 1391c87e0974 systemd[1]: Starting MySQL Server...

Apr 16 01:47:59 1391c87e0974 systemd[1]: Started MySQL Server.

 

获取mysql默认生成的密码

$ grep 'temporary password' /var/log/mysqld.log

2018-04-16T01:47:56.993269Z 1 [Note] A temporary password is generated for root@localhost: 2xbJEddd7f;3

 

修改密码

$ mysql -u root -p

Enter password:输入上面的密码,进入mysql

修改

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

这个密码一定要足够复杂,不然会提示密码不合法

 

这个其实与validate_password_policy的值有关。

validate_password_policy有以下取值:

PolicyTests Performed

0 or LOWLength

1 or MEDIUMLength; numeric, lowercase/uppercase, and special characters

2 or STRONGLength; numeric, lowercase/uppercase, and special characters; dictionary file

默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。

 

有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。

必须修改两个全局参数:

首先,修改validate_password_policy参数的值

mysql> set global validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

这样,判断密码的标准就基于密码的长度了。这个由validate_password_length参数来决定

mysql> select @@validate_password_length;

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

| @@validate_password_length |

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

|                          8 |

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

1 row in set (0.00 sec)

validate_password_length参数默认为8,它有最小值的限制,最小值为:

validate_password_number_count

+ validate_password_special_char_count

+ (2 * validate_password_mixed_case_count)

其中,validate_password_number_count指定了密码中数据的长度,validate_password_special_char_count指定了密码中特殊字符的长度,validate_password_mixed_case_count指定了密码中大小字母的长度

这些参数,默认值均为1,所以validate_password_length最小值为4,如果你显性指定validate_password_length的值小于4,尽管不会报错,但validate_password_length的值将设为4

如:

mysql> set global validate_password_length=1;

Query OK, 0 rows affected (0.00 sec)

mysql> select @@validate_password_length;

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

| @@validate_password_length |

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

|                          4 |

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

1 row in set (0.00 sec)

如果修改了validate_password_number_count,validate_password_special_char_count,validate_password_mixed_case_count中任何一个值,则validate_password_length将进行动态修改。

 

以上验证的前提是validate_password插件必须已经安装,MySQL5.7是默认安装的

 

 

mysql允许远程访问:

给192.168.1.100 权限访问

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.100' IDENTIFIED BY 'root用户的密码' WITH GRANT OPTION;

给任意IP 访问

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root用户的密码' WITH GRANT OPTION;

 

修改生效

mysql> flush privileges;

相关解决方案

最新解决方案