linux 下 yum 安装mysql

yum是一个用于管理rpm包的后台程序,用python写成,可以非常方便的解决rpm的依赖关系.在建立好yum服务器后,yum客户端可以通过http、ftp方式获得软件包,并使用方便的

1 rpm -qa | grep mysql 查看自己是否安装了MySQL数据库

结果;

mysql-server-5.1.73-8.el6_8.i686

mysql-libs-5.1.73-8.el6_8.i686

mysql-5.1.73-8.el6_8.i686

mysql-devel-5.1.73-8.el6_8.i686

2 卸载有两种方式,一种是普通删除,另一种是强力删除,当MySQL数据库有其它的依赖文件时,也进行删除。

  分别是:rpm -e mysql 和rpm -e --nodeps mysql

 

3 安装过程

  首先,我们通过命令:yum list | grep mysql 来查看yum上提供的数据库可下载版本。

yum -y install mysql mysql-server mysql-devel 在输入此命令

··········yum出错Error: Cannot find a valid baseurl for repo: base

解决方法如下(修改dns配置)

vi /etc/resolv.conf

在此文件最后加入:nameserver 8.8.8.8

 

4启动方式:service mysqld start

  chkconfig --list | grep mysqld来查看是否开机自动启动。如果2~5的都是on

[root@localhost ]# chkconfig --list | grep mysqld

mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off

 

  chkconfig mysqld on来设置成开机自动启动

[root@localhost ]# chkconfig mysqld on

[root@localhost ]# chkconfig --list | grep mysqld

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

  [root@localhost ]# service mysqld start

  Starting mysqld:  [  OK  ]

5 数据库密码设置

------------当用密码是无法登陆 就采取如下方法

1.service mysqld stop 先停止服务

2,/usr/bin/mysqld_safe --skip-grant-tables

3,重新克隆一个会话 变为root用户

4,输入  mysql>use mysql

mysql>update user set password=password("123456") where user="root";

mysql>flush privileges;

mysql>exit

5,正常启动 MySQL:/etc/init.d/mysql start? ?(service mysqld start)

6,用mysql -u root -p

123456 登陆

 

 

 

which mysql 查看mysql文件位置

/usr/bin/mysql --verbose --help | grep -A 1 'Default options' 可以针对这个目录通过一些命令查看配置文件在哪

 cat /etc/my.cnf 查看mysql数据库的配置信息文件-----其中datadir是MySQL数据库的存放路径

 

数据库的配置信息文件是etc/my.cnf

 

 

数据库日志文件 存放位置是:var/log/mysqld.log

 

 

 

 

vi /etc/init.d/mysqld  修改查看mysql的配置文件

===============加入这个 不用输密码 就能登陆==============================================

--skip-grant-tables

/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"

--log-error="$errlogfile" --pid-file="$mypidfile"

 

 

 select user,host,password from mysql.user;    查询用户列表(只能root登陆)

insert into mysql.user(Host,User,Password) values("localhost","kang","root");  添加用户

\q 退出数据库

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值