问题1 : MySQL Daemon failed to start.
解决方法:
因为我之前安装过mysql。 现在虽然rpm 删除安装包,但是没有删除完全。
[root@redhat6 yao]# rm -rf /var/lib/mysql/*
再运行: service mysqld start
正常运行
参考 : https://blog.youkuaiyun.com/hwijew/article/details/79582230
问题2 :
mysql> set password for 'root'@'localhost' = password('123456');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password('123456')' at line 1
因为安装的是mysql 8.0.12 版本。不再支持该语句。
参考: https://www.jb51.net/article/142025.htm
解决方法:
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> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter user 'root'@'%' identified by '123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决办法:
mysql> show variables like 'validate_password%'
-> ;
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
认证密码长度为8 。安全级别为: modium
mysql> set global validate_password.length =0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.policy =0;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 4 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.19 sec)
问题3 。。 不能远程访问
参考: https://www.cnblogs.com/xyabk/p/8967990.html
mysql> create user 'yao'@'%' identified by '123456';
mysql> grant all on *.* to 'yao'@'%';
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye
重启mysql服务
[root@redhat6 yao]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
远程登录成功:
[root@redhat7 yao]# mysql -h 192.168.1.63 -u yao -p
Enter password: