Red Hat 和Cent OS 低版本安装mysql

1、下载rpm安装文件

client:
[root@localhost mysql]wget http://dev.mysql.com/get/MySQL-client-5.6.13-1.el6.x86_64.rpm
server:
[root@localhost mysql]wget http://dev.mysql.com/get/MySQL-server-5.6.13-1.el6.x86_64.rpm
devel:
[root@localhost mysql]wget http://dev.mysql.com/get/MySQL-devel-5.6.13-1.el6.x86_64.rpm

2、 安装server、devel、client:

[root@localhost mysql]# rpm -ivh –replacefiles MySQL-server-5.6.13-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-server ########################################### [100%]
[root@localhost mysql]# rpm -ivh –replacefiles MySQL-client-5.6.13-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@localhost mysql]# rpm -ivh –replacefiles MySQL-devel-5.6.13-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:MySQL-devel ########################################### [100%]

要移除安装可以使用 rpm -e MySQL-server 、 rpm -e MySQL-devel、MySQL-client即可;

3、 初始化数据库:

命令:/usr/bin/mysql_install_db

4、启动mysql服务:

命令:service mysql start

使用命令ps -ef | grep mysql 查看mysql进程:

[root@localhost mysql]# ps -ef | grep mysql

root 3992 1 0 01:15 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe –datadir=/var/lib/mysql –pid-file=/var/lib/mysql/localhost.pid
mysql 4170 3992 2 01:15 pts/0 00:00:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –user=mysql –log-error=/var/log/mysqld.log –pid-file=/var/lib/mysql/localhost.pid –socket=/var/lib/mysql/mysql.sock
root 4199 3338 0 01:15 pts/0 00:00:00 grep mysql

5、重置密码:
1)更改/etc/my.cnf文件
[root@localhost mysql]# vi /etc/my.cnf
在[mysqld]下添加skip-grant-tables,保存退出。

2)重启mysql
[root@localhost mysql]service mysql restart

3)登录:
[root@localhost mysql]mysql -u root -p
Enter password:
这里直接按回车登录。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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.
4)选择数据库:
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

5)设置密码:
mysql> update user set password=(‘123456’) where user = ‘root’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

6)重新加载配置文件

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

7)退出
mysql> quit
Bye

8)更改/etc/my.cnf文件
[root@localhost mysql]# vi /etc/my.cnf
在[mysqld]下删除skip-grant-tables,保存退出

9)2)重启mysql
[root@localhost mysql]service mysql restart

好了,现在连接数据库访问了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值