centos6.5安装mysql

前端之家收集整理的这篇文章主要介绍了centos6.5安装mysql前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.卸载centos6.5本身所安装的MysqL

yum remove MysqL MysqL-server MysqL-libs MysqL-server;

find / -name MysqL 将找到的都删掉 rm -fr

rpm -qa|grep -i MysqL 查看还有么没有MysqL,如果有的话,使用

rpm -e –nodeps 包名 删除

2.安装MysqL

下载https://cdn.MysqL.com//Downloads/MysqL-5.7/MysqL-5.7.18-1.el6.x86_64.rpm-bundle.tar

并解压tar包

其中最简单的安装MysqL-server服务,只需要安装如下4个软件包即可,我们可以使用rpm -ivh命令进行安装

MysqL-community-common-5.7.18-1.el6.x86_64.rpm
MysqL-community-libs-5.7.18-1.el6.x86_64.rpm --(依赖于common)
MysqL-community-client-5.7.18-1.el6.x86_64.rpm --(依赖于libs)
MysqL-community-server-5.7.18-1.el6.x86_64.rpm --(依赖于client、common)

rpm -qi MysqL-community-server 可以查看MysqL版本

3.安装好后初始化MysqL

service MysqLd start

默认会在/var/log/MysqLd.log下生成随机密码,用户为root

cat /var/log/MysqLd.log | grep password

[root@localhost MysqL]# cat /var/log/MysqLd.log | grep password
2017-04-10T22:32:56.944884Z 1 [Note] A temporary password is generated for root@localhost: FD?Sfhgf?6gh
2017-04-10T22:33:04.421493Z 0 [Note] Execution of init_file '/var/lib/MysqL/install-validate-password-plugin.kR64JZ.sql' started.
2017-04-10T22:33:04.432952Z 0 [Note] Execution of init_file '/var/lib/MysqL/install-validate-password-plugin.kR64JZ.sql' ended.
2017-04-10T22:33:08.044435Z 0 [Note] Shutting down plugin 'sha256_password'
2017-04-10T22:33:08.044438Z 0 [Note] Shutting down plugin 'MysqL_native_password'
2017-04-10T22:33:09.691686Z 3 [Note] Access denied for user 'UNKNOWN_MysqL_USER'@'localhost' (using password: NO)
2017-04-10T22:37:37.987539Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2017-04-10T22:39:57.070282Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2017-04-10T22:41:45.424458Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)

在第一行中找到密码,FD?Sfhgf?6gh,然后按照root用户登录,输入密码

[root@localhost MysqL]# MysqL -u root -p
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 8
Server version: 5.7.18


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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

可以使用MysqL了。为了保证MysqL可以远程访问,需要授予权限,如下命令:

MysqL>grant all privileges on *.* toroot@'%'identified by '你的密码';
MysqL> flush privileges;

4 停止MysqL

service MysqLd stop

5 重启MysqL

service MysqLd restart

猜你在找的CentOS相关文章