mysql-community-client-5.7.9-1.el6.x86_64.rpm
mysql-community-common-5.7.9-1.el6.x86_64.rpm
mysql-community-libs-5.7.9-1.el6.x86_64.rpm
mysql-community-server-5.7.9-1.el6.x86_64.rpm
安装顺序如下:
[root@iZbp19419cu2b8cdfbb43jZ /]# rpm -ivh mysql-community-common-5.7.9-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
[root@iZbp19419cu2b8cdfbb43jZ /]# rpm -ivh mysql-community-libs-5.7.9-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
[root@iZbp19419cu2b8cdfbb43jZ /]# rpm -ivh mysql-community-client-5.7.9-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@iZbp19419cu2b8cdfbb43jZ /]# rpm -ivh mysql-community-server-5.7.9-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
以安全模式启动mysql服务:
[root@iZbp19419cu2b8cdfbb43jZ /]# mysqld_safe --skip-grant-tables&
[1] 8588
[root@iZbp19419cu2b8cdfbb43jZ /]# 171221 15:39:36 mysqld_safe Logging to '/var/log/mysqld.log'.
171221 15:39:36 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe 命令的参数具体使用可以通过命令mysqld_safe --help&& man mysqld_safe 查看
[root@iZbp19419cu2b8cdfbb43jZ /]# mysqld_safe --help
Usage: /usr/bin/mysqld_safe [OPTIONS]
--no-defaults Don't read the system defaults file
--defaults-file=FILE Use the specified defaults file
--defaults-extra-file=FILE Also use defaults from the specified file
--ledir=DIRECTORY Look for mysqld in the specified directory
--open-files-limit=LIMIT Limit the number of open files
--core-file-size=LIMIT Limit core files to the specified size
--timezone=TZ Set the system timezone
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
--nice=NICE Set the scheduling priority of mysqld
--plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if
VERSION is given
--skip-kill-mysqld Don't try to kill stray mysqld processes
--syslog Log messages to syslog with 'logger'
--skip-syslog Log messages to error log (default)
--syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger'
输入mysql后直接回车
[root@iZbp19419cu2b8cdfbb43jZ /]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
修改本地连接root用户的密码:
mysql> alter user 'root'@'%' identified by 'BhL*&^!@#qwe';
ERROR 1131 (42000): You are using MySQL as an anonymous user and anonymous users are not allowed to change passwords
解决:
使用语句更新成功:
>update mysql.user set authentication_string=password('XXXXXX') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
>flush privileges;
详见:https://bugs.mysql.com/bug.php?id=79027, https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
重新启动服务:pkill mysqld && service mysqld start
mysql -uroot -pXXXXXX
>use mysql;
执行alter user语句修改密码时候报错: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
修改变量的值validate_password_policy;变量的值可以有0,1,2,从小到大密码强度依次增强;变量validate_password_length也是必须的
弱密码强度只需要设置 : set global validate_password_policy=0,set global validate_password_length=X;
中|强密码轻度需要设置:
set global validate_password_policy=0,
set global validate_password_length=X;
set global validate_password_mixed_case_count=X;
set global validate_password_number_count=X;
set global validate_password_special_char_count=X;
解决:参考官方文档https://dev.mysql.com/doc/refman/5.7/en/validate-password-plugin.html,https://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html
确认配置文件my.cnf中几个变量
log-bin=/XXX/XXX/mysql-bin
innodb_file_per_table=1
log-error=/var/log/mysqld.log
pid-file=/xxxx/xxx/mysqld.pid
重启mysql服务