`
gary0416
  • 浏览: 330760 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

linux下安装mysql

阅读更多

1.从

 

http://mysql.saudi.net.sa/Downloads/MySQL-5.1/MySQL-server-community-5.1.57-1.rhel5.i386.rpm

下载mysql server
下载mysql client

2.运行
rpm -ivh MySQL-server-community-5.1.57-1.rhel5.i386.rpm

[root@localhost temp]# rpm -ivh MySQL-server-community-5.1.57-1.rhel5.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server-community ########################################### [100%]

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 localhost.localdomain 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.

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

[root@localhost temp]# 
 3.启动mysql
service mysql start

4.安装mysql client
rpm -ivh MySQL-client-community-5.1.57-1.rhel5.i386.rpm
[root@localhost temp]# rpm -ivh MySQL-client-community-5.1.57-1.rhel5.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client-community ########################################### [100%]
[root@localhost temp]# 
 5.设置mysql密码
/usr/bin/mysql_secure_installation
提示输入原密码,默认是空,所以直接回车
为root用户设置密码,选择y并输入2次密码
删除匿名账号,选择y
是否禁止root用户远程登录,此项根据实际需要选择
是否删除test数据库,选择y
是否reload使设置立即生效,选择y
[root@localhost temp]# /usr/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@localhost temp]# 
 

搞定

测试
mysql -u root -p
输入密码
显示
[root@localhost temp]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.57-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
 
测试成功


目录

数据库目录

/var/lib/mysql/

配置文件

/usr/share/mysql

相关命令(mysqldump等)

/usr/bin

启动脚本

/etc/rc.d/init.d/mysql


防火墙开3306端口

vi /etc/sysconfig/iptables
添加
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics