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 *.* to root@'%' identified by '你的密码';
mysql> flush privileges;

4 停止mysql

service mysqld stop

5 重启mysql

service mysqld restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值