国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > MySql > 新手一步一步教你在Linux下安装MySQL

新手一步一步教你在Linux下安装MySQL

来源:程序员人生   发布时间:2014-04-30 08:06:45 阅读次数:3019次
     终于成功地在linux上面装上mysql了。兴奋之余写了这篇东西来纪念一下,顺便做个笔记,以便以后遇到问题时可以查阅。

首先看看安装需要用到的所有的包吧。

[root@localhost6 mysql]# ls

mysql-5.0.37-2.fc7.i386.rpm mysql-server-5.0.37-2.fc7.i386.rpm unixODBC-2.2.12-2.fc7.i386.rpm

mysql-connector-odbc-3.51.12-2.2.i386.rpm perl-DBD-MySQL-3.0008-1.fc7.i386.rpm

mysql-libs-5.0.37-2.fc7.i386.rpm perl-DBI-1.53-2.fc7.i386.rpm

         接下来就是安装数据库的过程了。因为各个包都存在着一定的依赖关系的,所以大家在安装时最好按照我的安装顺序来安装,虽然我不敢说这个是唯一正确的顺序,但是至少是可行的一个按照顺序。

[root@localhost6 mysql]# rpm -ivh perl-DBI-1.53-2.fc7.i386.rpm

warning: perl-DBI-1.53-2.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:perl-DBI ########################################### [100%]

[root@localhost6 mysql]# rpm -ivh perl-DBD-MySQL-3.0008-1.fc7.i386.rpm

warning: perl-DBD-MySQL-3.0008-1.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:perl-DBD-MySQL ########################################### [100%]

[root@localhost6 mysql]# rpm -ivh mysql-libs-5.0.37-2.fc7.i386.rpm

warning: mysql-libs-5.0.37-2.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:mysql-libs ########################################### [100%]

[root@localhost6 mysql]# rpm -ivh mysql-5.0.37-2.fc7.i386.rpm

warning: mysql-5.0.37-2.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:mysql ########################################### [100%]

[root@localhost6 mysql]# rpm -ivh mysql-server-5.0.37-2.fc7.i386.rpm

warning: mysql-server-5.0.37-2.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:mysql-server ########################################### [100%]

        到此为止,整个mysql已经安装完成了。接下来是启动mysql的守护进程。过程大致如下

[root@localhost6 mysql]# chown -R mysql:mysql /var/lib/mysql

[root@localhost6 mysql]# /etc/init.d/mysqld start

初始化 MySQL 数据库: Installing all prepared tables

Fill help tables

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 localhost6.localdomain6 password 'new-password'

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 the benchmarks in the 'sql-bench' directory:

cd sql-bench ; perl run-all-tests

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

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

[确定]

启动 MySQL[确定]

        当你见到上面这个页面时,恭喜你,你安装成功了。现在你只要在终端输入mysql就可以使用了。我们来试试启动mysql来看看。

[root@localhost6 mysql]# mysql

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 2

Server version: 5.0.37 Source distribution

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

成功启动了。

mysql> quit;

Bye

退出成功。

        但是一般情况下要进行开发必然要用其他语言来连接mysql的,所以肯定要装odbc。安装过程如下。

[root@localhost6 mysql]# rpm -ivh unixODBC-2.2.12-2.fc7.i386.rpm

warning: unixODBC-2.2.12-2.fc7.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:unixODBC ########################################### [100%]

[root@localhost6 mysql]# rpm -ivh mysql-connector-odbc-3.51.12-2.2.i386.rpm

warning: mysql-connector-odbc-3.51.12-2.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2

Preparing... ########################################### [100%]

1:mysql-connector-odbc ########################################### [100%]

         odbc也安装成功。现在你就可以使用了mysql来进行开发了。至于怎么设置和使用,那就要看你自己对mysql的掌握程度了,我不在这献丑了。希望这篇文章能够帮助到其他和我一样的菜鸟吧。

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生