mysql> SET GLOBAL validate_password.policy=LOW; mysql> SET GLOBAL validate_password.length=8; mysql> SET GLOBAL validate_password.letter_count=1; mysql> SET GLOBAL validate_password.digit_count=1; mysql> SET GLOBAL validate_password.special_char_count=1;
4)设置简单好记的密码
1 2 3 4
set password=password("123456");
set password for 'root'@'localhost'=password('123456'); # 修改root账号登陆密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; # 修改root账号登陆密码
5)授权
1 2 3 4 5 6 7 8 9 10 11 12 13 14
###### 方法一 ########## GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION; ###### 方法二 ########## # 进入msyql库 use mysql # 查询user表 select user, host from user; # 修改user表,把Host表内容修改为% update user set host="%" where user="root";
8)刷新
1
flush privileges;
9)退出
1
quit;
3. 一些小坑
Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: Failed dependencies:
1 2 3 4 5 6 7 8
rpm -ivh mysql-community-server-5.7.26-1.el6.x86_64.rpm warning: mysql-community-server-5.7.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies: libsasl2.so.2()(64bit) is needed by mysql-community-server-5.7.26-1.el6.x86_64
[root@zhangxxx init.d]# systemctl start mysqld Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [root@zhangcool-cooler01 init.d]# service mysqld start Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]
[root@zhangxxx init.d]# systemctl status mysqld.service ● mysqld.service - SYSV: MySQL database server. Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2018-07-06 13:43:52 CST; 1min 2s ago Docs: man:systemd-sysv-generator(8) Process: 3886 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE) Jul 06 13:43:51 zhangcool-cooler01 systemd[1]: Starting SYSV: MySQL database server.... Jul 06 13:43:52 zhangcool-cooler01 mysqld[3886]: MySQL Daemon failed to start. Jul 06 13:43:52 zhangcool-cooler01 mysqld[3886]: Starting mysqld: [FAILED] Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: mysqld.service: control process exited, code=exited status=1 Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: Failed to start SYSV: MySQL database server.. Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: Unit mysqld.service entered failed state. Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: mysqld.service failed. [root@zhangcool-cooler01 init.d]# journalctl -xe Jul 06 13:42:58 zhangcool-cooler01 polkitd[477]: Unregistered Authentication Agent for unix-process:3597:8111728 (system bus name :1.355, object path Jul 06 13:43:51 zhangcool-cooler01 polkitd[477]: Registered Authentication Agent for unix-process:3880:8117203 (system bus name :1.356 [/usr/bin/pktt Jul 06 13:43:51 zhangcool-cooler01 systemd[1]: Starting SYSV: MySQL database server.... -- Subject: Unit mysqld.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysqld.service has begun starting up. Jul 06 13:43:52 zhangcool-cooler01 mysqld[3886]: MySQL Daemon failed to start. Jul 06 13:43:52 zhangcool-cooler01 mysqld[3886]: Starting mysqld: [FAILED] Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: mysqld.service: control process exited, code=exited status=1 Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: Failed to start SYSV: MySQL database server.. -- Subject: Unit mysqld.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysqld.service has failed. -- -- The result is failed. Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: Unit mysqld.service entered failed state. Jul 06 13:43:52 zhangcool-cooler01 systemd[1]: mysqld.service failed. Jul 06 13:43:52 zhangcool-cooler01 polkitd[477]: Unregistered Authentication Agent for unix-process:3880:8117203 (system bus name :1.356, object path
查看mysql日志,分析mysql启动过程有何异常
1 2 3 4
[root@zhangcool-cooler01 init.d]# vi /var/log/mysqld.log 2021-07-06T05:43:52.466691Z 0 [Note] Server socket created on IP: '::'. 2021-07-06T05:43:52.469258Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory) 2021-07-06T05:43:52.469270Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory