liunx 安装mysql

先用下面命令查看你的机器上是否有别的版本的mysql
rpm -qa|grep mysql
mysql-3.23.49-3
用下面命令卸载掉,并把/var/lib/mysql/ 下的文件删除。
[root@wangde mysql]#rpm -e  mysql-3.23.49-3
[root@wangde mysql]#rm -rf /var/lib/mysql

[root@wangde mysql]# ls
MySQL-client-5.5.11-1.linux2.6.i386.rpm
MySQL-server-5.5.11-1.linux2.6.i386.rpm
MySQL-shared-5.5.11-1.linux2.6.i386.rpm
[root@wangde mysql]# rpm -ivh MySQL-shared-5.5.11-1.linux2.6.i386.rpm
警告:MySQL-shared-5.5.11-1.linux2.6.i386.rpm: V3 DSA 簽章:NOKEY, key ID 5072e1 f5
準備中...                ########################################### [100%]
   1:MySQL-shared           ########################################### [100%]
[root@wangde mysql]#
[root@wangde mysql]# rpm -ivh MySQL-server-5.5.11-1.linux2.6.i386.rpm
警告:MySQL-server-5.5.11-1.linux2.6.i386.rpm: V3 DSA 簽章:NOKEY, key ID 5072e1 f5
準備中...                ########################################### [100%]
        已經安裝 MySQL-server-5.5.11-1.linux2.6 套件
[root@wangde mysql]# rpm -e MySQL-server-5.5.11-1.linux2.6
[root@wangde mysql]# rpm -ivh MySQL-server-5.5.11-1.linux2.6.i386.rpm
警告:MySQL-server-5.5.11-1.linux2.6.i386.rpm: V3 DSA 簽章:NOKEY, key ID 5072e1 f5
準備中...                ########################################### [100%]
   1:MySQL-server           ########################################### [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 wangde 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!

 

Notes regarding SELinux on this platform:
=========================================

The default policy might cause server startup to fail because it is
not allowed to access critical files.  In this case, please update
your installation.

The default policy might also cause inavailability of SSL related
features because the server is not allowed to access /dev/random
and /dev/urandom. If this is a problem, please do the following:

  1) install selinux-policy-targeted-sources from your OS vendor
  2) add the following two lines to /etc/selinux/targeted/src/policy/domains/pro gram/mysqld.te:
       allow mysqld_t random_device_t:chr_file read;
       allow mysqld_t urandom_device_t:chr_file read;
  3) cd to /etc/selinux/targeted/src/policy and issue the following command:
       make load


[root@wangde mysql]#
[root@wangde mysql]# ls
MySQL-client-5.5.11-1.linux2.6.i386.rpm
MySQL-server-5.5.11-1.linux2.6.i386.rpm
MySQL-shared-5.5.11-1.linux2.6.i386.rpm
[root@wangde mysql]# rpm -ivh MySQL-client-5.5.11-1.linux2.6.i386.rpm
警告:MySQL-client-5.5.11-1.linux2.6.i386.rpm: V3 DSA 簽章:NOKEY, key ID 5072e1 f5
準備中...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@wangde mysql]# mysqladmin -u root password root
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql .sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' ex ists!
[root@wangde mysql]# service mysql start
Starting MySQL...                                          [  OK  ]
[root@wangde mysql]# mysqladmin -u root password root
[root@wangde mysql]# mysqladmin -u root -h wangde password root
[root@wangde mysql]# service mysql restart
Shutdown MySQL...                                          [  OK  ]
Starting MySQL...                                          [  OK  ]
[root@wangde mysql]#
 下面就介绍一下这几个目录。

   1、数据库目录
   /var/lib/mysql/

   2、配置文件
   /usr/share/mysql(mysql.server命令及配置文件)

   3、相关命令
   /usr/bin(mysqladmin mysqldump等命令)

   4、启动脚本
   /etc/rc.d/init.d/(启动脚本文件mysql的目录)
  五、修改登录密码

   MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

   1、命令
   usr/bin/mysqladmin -u root password 'new-password'
   格式:mysqladmin -u用户名 -p旧密码 password 新密码

   2、例子
   例1:给root加个密码123456。
   键入以下命令 :
   [root@wangde local]# /usr/bin/mysqladmin -u root password 123456
   注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。

   3、测试是否修改成功
   1)不用密码登录
   [root@wangde local]# mysql
   ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
   显示错误,说明密码已经修改。
   2)用修改后的密码登录
   [root@wangde /]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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.

mysql>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值