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
好了,现在连接数据库访问了!