redhat6.9安装 mysql 出现问题

在Redhat6.9上安装MySQL 8.0.12时遇到启动失败和密码设置错误的问题。通过删除MySQL遗留数据,解决启动问题;针对新版本不支持的SQL语法,更新用户密码策略并重置root密码;最后配置允许远程访问。通过这些步骤,成功安装并运行MySQL服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题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: 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值