VM虚拟机CentOS7下安装MySQL5.7版本遇到的一些问题

先登录MySQL:

安装MySQL包时,安装顺序:

common→libs→client→server

安装最后一个server时报了一个错误:

 

提示依赖检测失败,libsasl2.so.2()(64bit) 被 mysql-community-server-5.7.19-1.el6.x86_64 需要;

 

解决方法是在后面加两个参数:

 

安装完成server之后初始化报错:

原因是data目录下不能存在文件,需要是空文件夹,找到该目录发现自动生成了四个文件:

 

删除之后检查目录权限:
一定确保datadir设置的路径的所有组和所有者是mysql,如果不是则运行下面命令更改,如果不改则初始化会失败。

chown mysql.mysql /var/run/mysqld/(chown mysql:mysql -R /var/lib/mysql)

 


之后输入 service mysqld start 来开启MySQL

 

再从vi编译器中找到生成的密码:

 


最后登录:

 

完成。


    hostnamectl set-hostname xxx
使用这种方式修改,可以永久性的修改主机名称!


修改MySQL的root密码:

先登录MySQL:

 

[root@slave2 ~]# 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.
[失败]
[root@slave2 ~]# mkdir -p /var/run/mysqld
[root@slave2 ~]# chown mysql.mysql /var/run/mysqld/
[root@slave2 ~]# service mysqld start
Starting mysqld (via systemctl):  [  确定  ]
[root@slave2 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19

Copyright (c) 2000, 2017, 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> 
mysql> 


然后修改:

 

 

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)


设置完之后输入修改指令:

mysql> set password for 'root'@'localhost'=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)


修改成功,尝试登录:

[root@slave2 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> 
mysql> 


登录成功

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值