码迷,mamicode.com
首页 > 数据库 > 详细

Linux安装MySql

时间:2014-05-05 10:12:56      阅读:502      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   code   java   

本文记录Linux安装MySql过程。

环境:OS:Centos 6.5 x64 & MySql 5.1 x64

1、系统检查

检查是否已经安装MySql数据库。

bubuko.com,布布扣
[root@master ~]# rpm -qa | grep mysql
bubuko.com,布布扣

如果有安装,先卸载已经安装的MySql数据库。

bubuko.com,布布扣
[root@master ~]# rpm -e mysql  //普通删除模式
[root@master ~]# rpm -e --nodeps mysql  //强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
bubuko.com,布布扣

2、安装数据库

bubuko.com,布布扣
[root@master ~]# yum install -y mysql-server mysql mysql-devel
bubuko.com,布布扣

查看安装情况

bubuko.com,布布扣
[root@master ~]# rpm -qi mysql-server
Name        : mysql-server                 Relocations: (not relocatable)
Version     : 5.1.73                            Vendor: CentOS
Release     : 3.el6_5                       Build Date: 2014年02月13日 星期四 03时42分39秒
Install Date: 2014年04月17日 星期四 19时38分28秒      Build Host: c6b9.bsys.dev.centos.org
Group       : Applications/Databases        Source RPM: mysql-5.1.73-3.el6_5.src.rpm
Size        : 25882723                         License: GPLv2 with exceptions
Signature   : RSA/SHA1, 2014年02月13日 星期四 03时48分08秒, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.mysql.com
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.
bubuko.com,布布扣

3、管理数据库

启动数据库

bubuko.com,布布扣
[root@master ~]# service mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password new-password
/usr/bin/mysqladmin -u root -h master password new-password

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[确定]
正在启动 mysqld: [确定]
bubuko.com,布布扣

为MySql的root用户设置密码,初始没有密码。

bubuko.com,布布扣
[root@master ~]# mysqladmin -u root password ‘mysql‘
bubuko.com,布布扣

登陆数据库

bubuko.com,布布扣
[root@master ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution

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.
bubuko.com,布布扣

Linux安装MySql,布布扣,bubuko.com

Linux安装MySql

标签:des   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/guarder/p/3707895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!