Linux安装MySql

本文记录Linux安装MySql过程。

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

1、系统检查

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

[root@master ~]# rpm -qa | grep mysql

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

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

2、安装数据库

[root@master ~]# yum install -y mysql-server mysql mysql-devel

查看安装情况

[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.

3、管理数据库

启动数据库

[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: [确定]

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

[root@master ~]# mysqladmin -u root password ‘mysql‘

登陆数据库

[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.

Linux安装MySql,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。