linux安装Mysql

Redhat 5 下安装Mysql


1.下载Server和client 
Server:
Java代码   收藏代码
  1. wget http://mysql.easynet.be/Downloads/MySQL-5.5/MySQL-server-5.5.25-1.rhel5.x86_64.rpm  


Client:
Java代码   收藏代码
  1. wget http://mysql.easynet.be/Downloads/MySQL-5.5/MySQL-client-5.5.25-1.rhel5.x86_64.rpm  


2.安装server和client 

安装Server 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]#  rpm -ivh MySQL-server-4.0.16-0.i386.rpm  
  2. error: open of MySQL-server-4.0.16-0.i386.rpm failed: No such file or directory  
  3. [root@inc-platform-dev-153-135 mysql]# rpm -ivh MySQL-server-5.5.25-1.rhel5.x86_64.rpm   
  4. Preparing...                ########################################### [100%]  
  5.    1:MySQL-server           ########################################### [100%]  
  6.   
  7. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !  
  8. To do so, start the server, then issue the following commands:  
  9.   
  10. /usr/bin/mysqladmin -u root password 'new-password'  
  11. /usr/bin/mysqladmin -u root -h inc-platform-dev-153-135.hst.bjc.kfc.alidc.net password 'new-password'  
  12.   
  13. Alternatively you can run:  
  14. /usr/bin/mysql_secure_installation  
  15.   
  16. which will also give you the option of removing the test  
  17. databases and anonymous user created by default.  This is  
  18. strongly recommended for production servers.  
  19.   
  20. See the manual for more instructions.  
  21.   
  22. Please report any problems with the /usr/bin/mysqlbug script!  

启动Server 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# service mysql start  
  2. Starting MySQL..                                           [  OK  ]  
  3. [root@inc-platform-dev-153-135 mysql]# netstat -an|grep 3306  
  4. tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LIST  

安装Client 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# rpm -ivh MySQL-client-5.5.25-1.rhel5.x86_64.rpm   
  2. Preparing...                ########################################### [100%]  
  3.    1:MySQL-client           ########################################### [100%]  


3.修改mysql的root用户密码 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# /usr/bin/mysqladmin -u root password \'javaman\'   

3.登录MySql 
登录: 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# mysql -u root -p javaman  
  2. Enter password:   
  3. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)  

无法登录要修改配置: 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# service mysql stop  
  2. Shutting down MySQL.                                       [  OK  ]  
  3. [root@inc-platform-dev-153-135 mysql]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  
  4. [123797  
  5. [root@inc-platform-dev-153-135 mysql]# 120603 13:18:12 mysqld_safe Logging to '/var/lib/mysql/inc-platform-dev-153-135.hst.bjc.kfc.alidc.net.err'.  
  6. 120603 13:18:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
  7.   
  8. [root@inc-platform-dev-153-135 mysql]# mysql -u root mysql  
  9. Reading table information for completion of table and column names  
  10. You can turn off this feature to get a quicker startup with -A  
  11.   
  12. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  13. Your MySQL connection id is 1  
  14. Server version: 5.5.25 MySQL Community Server (GPL)  
  15.   
  16. Copyright (c) 20002011, Oracle and/or its affiliates. All rights reserved.  
  17.   
  18. Oracle is a registered trademark of Oracle Corporation and/or its  
  19. affiliates. Other names may be trademarks of their respective  
  20. owners.  
  21.   
  22. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  23.   
  24. mysql> UPDATE user SET Password=PASSWORD('javaman') where USER='root';  
  25. Query OK, 4 rows affected (0.01 sec)  
  26. Rows matched: 4  Changed: 4  Warnings: 0  
  27.   
  28. mysql> flush privileges;  
  29. Query OK, 0 rows affected (0.00 sec)  

  30. mysql> quit  
  31. Bye  
  32. [root@inc-platform-dev-153-135 mysql]# services mysql restart  
  33. -bash: services: command not found  
  34. [root@inc-platform-dev-153-135 mysql]# service mysql restart  
  35. Shutting down MySQL.120603 13:20:26 mysqld_safe mysqld from pid file /var/lib/mysql/inc-platform-dev-153-135.hst.bjc.kfc.alidc.net.pid ended  
  36.                                                            [  OK  ]  
  37. Starting MySQL..                                           [  OK  ]  
  38. [1]+  Done                    mysqld_safe --user=mysql --skip-grant-tables --skip-networking  
  39.   

重新登录 
Java代码   收藏代码
  1. [root@inc-platform-dev-153-135 mysql]# mysql -uroot -pjavaman mysql  
  2. Reading table information for completion of table and column names  
  3. You can turn off this feature to get a quicker startup with -A  
  4.   
  5. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  6. Your MySQL connection id is 1  
  7. Server version: 5.5.25 MySQL Community Server (GPL)  
  8.   
  9. Copyright (c) 20002011, Oracle and/or its affiliates. All rights reserved.  
  10.   
  11. Oracle is a registered trademark of Oracle Corporation and/or its  
  12. affiliates. Other names may be trademarks of their respective  
  13. owners.  
  14.   
  15. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  16.   
  17. mysql> show databases;  
  18. +--------------------+  
  19. | Database           |  
  20. +--------------------+  
  21. | information_schema |  
  22. | mysql              |  
  23. | performance_schema |  
  24. | test               |  
  25. +--------------------+  
  26. 4 rows in set (0.00 sec)  
  27.   
  28. mysql>   
  29.    

成功了. 
4.远程登录 
当企图远程登录mysql时候,有可能报错“Host'xxx.xxx.xxx.xx' is not allowed to connect to this MySQL server".在MySql Server 本机修改如下: 
Java代码   收藏代码
  1. mysql> UPDATE user SET user='root' where host='localhost';   
  2. mysql> update user set host = '%' where user = 'root';  
  3. mysql> select host, user from user;  
  4. +------------------------------------------------+------+  
  5. | host                                           | user |  
  6. +------------------------------------------------+------+  
  7. | %                                              | root |  
  8. 127.0.0.1                                      | root |  
  9. | ::1                                            | root |  
  10. | inc-platform-dev-153-135.hst.bjc.kfc.alidc.net |      |  
  11. | inc-platform-dev-153-135.hst.bjc.kfc.alidc.net | root |  
  12. | localhost                                      | root |  
  13. +------------------------------------------------+------+  
  14. 6 rows in set (0.00 sec)  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值