Home > Database > Mysql Tutorial > body text

CentOS下MySQL数据库安装

WBOY
Release: 2016-06-01 13:06:46
Original
1052 people have browsed it

CentOS

前辈们总是说,要边学边记录,要总结。所以,开始把每天学到的内容一点一点记录。

复杂的理论不懂,只会目前安装,安好后就开始玩咯!

1、在官网下载相应的rpm安装包

下载地址: http://dev.mysql.com/downloads/mysql/5.6.html#downloads

比如:我只下载了这三个。

2、鄙人就用rpm命令安装(相对较熟悉)

其实,这是应该是第3步

#rpm -ivh MySQL-client-5.6.19-1.el6.i686.rpm#rpm -ivh MySQL-devel-5.6.19-1.el6.i686.rpm#rpm -ivh MySQL-server-5.6.19-1.el6.i686.rpm
Copy after login

安装后 输入(重启数据库):service mysql restart

出错:mysql  unrecognized service

查了原因,是以前的mysql 没有删除的缘故~~故删之!

3、删除原有的mysql

先查找原来有哪些 rpm -qa|grep mysql

将以上三个一一删除:

删除后再回到步骤2,重新安装。

4、修 改root 密码(这个root账号是mysql的root账号,非Linux的root账号) 。

修改密码输入:#mysqladmin -u root password 'root'  <br>然后又出错(┬_┬)<br>error:‘Access denied for user 'root'@'localhost'’<br>
Copy after login

然后又是百度,使用下面方法可以解决问题:

# service mysql stop#mysqld_safe --user=mysql --skip-grant-tables --skip-networking  mysql -u root mysqlmysql> UPDATE user SET Password=PASSWORD('newpassword(设置新密码)') where USER='root';mysql> FLUSH PRIVILEGES;mysql> quit# /etc/init.d/mysql restart# mysql -uroot -pEnter password: 
Copy after login

5、测试安装是否成功:

输入:mysql> show databases;

分号一定要加,否则会显示出错。

但即使我加了分号后,还是出错了(T^T)

ERROR 1820 (HY00):You must SET PASSWORD before executing this statement

我再一次见证了百度的强大

输入:mysql>  SET PASSWORD = PASSWORD('123456(你的密码)');

重新设置一次密码!

然后,好像真的可以了~~

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template