Home  >  Article  >  Database  >  CentOS下安装MySQL Server和MySQL Client

CentOS下安装MySQL Server和MySQL Client

WBOY
WBOYOriginal
2016-06-07 17:32:521403browse

CentOS下安装MySQL Server和MySQL Client

1. 首先检查是否已经安装了MySQL或者mysql,命令:

rpm –qa |grep MySQL

rpm –qa | grep mysql

由于这里讲的是安装,所以若mysql-client和mysql-server都有了,可以不安装,直接使用即可,,否则删除由上面命令列出的相关程序。用rpm –e ***(这里***表示列表的东西) – nodeps(如 rpm –e MySQL *** --nodeps)

2. 从这个网址下载一下两个文件:

MySQL-client-5.7.1_m11-2.linux_glibc2.5.i386.rpm

MySQL-server-5.7.1_m11-2.linux_glibc2.5.i386.rpm

(这里32位的下载i386的,64位下载x86的)

3. 安装MySQL

把以上两个文件放到系统/opt/mysql/文件夹下。

使用rpm –ivh /opt/mysql/MySQL-server-5.7.1_m11-2.linux_glibc2.5.i386.rpm

使用rpm –ivh /opt/mysql/MySQL-client-5.7.1_m11-2.linux_glibc2.5.i386.rpm

若有出现安装进度,且一切顺利,则一般都能成功,否则可能是第一步中没有删除完整,重新检查是否删除完整。

4. 用命令输入/etc/init.d/mysql start 可能会出现一下几种错误:

1. 之前的mysql进程在使用 ,使用命令ps –e |grep mysql

用命令kill –9 (查到的进程ID)

2. 出现PID错误,或者说/usr/**/**/lock.*类似这种文件提示的,用rm命令删除这些文件。有些如/*/.pid文件出现的,则退回该文件所在的父文件进行相关的删除

5. 重新输入/etc/init.d/mysql start即表示启动成功。

输入rpm –qa |grep MySQL(新版本的为这个),若输出server和client则安装正常

rpm –qa | grep mysql

6. 添加密码,命令:/usr/bin/mysqladmin –u root password ‘你要添加的密码’

如:/usr/bin/mysqladmin –u root password ‘public123’

7. 下次进入时就得输入mysql –u root –p。然后系统提示输入密码

8. 如果之前安装过mysql并设置过密码的,那么重新的安装的将会是一个新的密码。那么忘记root密码或者不知道这个新密码的可以这么做。首先,service mysqld stop。然后mysqld_safe –skip-grant-tables &.接着,输入mysql –u root。选择 use mysql。最后update user set password=password(‘123’) where user=’root’;刷新:flush privileges;重启即可使用新的密码了。

推荐阅读:

MySQL完整安装和主从双机配置

RHEL6平台rpm方式安装MySQL数据库

RedHat 6.3安装MySQL-server-5.6.13-1.el6.x86_64.rpm

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn