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)  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章