MySQL5.1.71安装详细过程

x33g5p2x  于2020-09-08 发布在 Mysql  
字(8.0k)|赞(0)|评价(0)|浏览(982)

一、上传MySQL

二、安装MySQL

卸载自带mysql

  1. [root@hadoop05 mysql]# rpm -qa | grep mysql
  2. mysql-libs-5.1.71-1.el6.i686
  3. [root@hadoop05 mysql]# rpm -e mysql-libs-5.1.71-1.el6.i686 --nodeps
  4. [root@hadoop05 mysql]# rpm -qa | grep mysql
  5. [root@hadoop05 mysql]#

安装mysql

  1. [root@hadoop05 mysql]# rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm
  2. Preparing... ########################################### [100%]
  3. 1:MySQL-server ########################################### [100%]
  4. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  5. To do so, start the server, then issue the following commands:
  6. /usr/bin/mysqladmin -u root password 'new-password'
  7. /usr/bin/mysqladmin -u root -h hadoop05 password 'new-password'
  8. Alternatively you can run:
  9. /usr/bin/mysql_secure_installation
  10. which will also give you the option of removing the test
  11. databases and anonymous user created by default. This is
  12. strongly recommended for production servers.
  13. See the manual for more instructions.
  14. Please report any problems with the /usr/bin/mysqlbug script!
  15. Starting MySQL.. SUCCESS!
  16. [root@hadoop05 mysql]# rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm
  17. Preparing... ########################################### [100%]
  18. 1:MySQL-client ########################################### [100%]
  19. [root@hadoop05 mysql]# /usr/bin/mysql_secure_installation
  20. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
  21. SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
  22. In order to log into MySQL to secure it, we'll need the current
  23. password for the root user. If you've just installed MySQL, and
  24. you haven't set the root password yet, the password will be blank,
  25. so you should just press enter here.
  26. Enter current password for root (enter for none):
  27. OK, successfully used password, moving on...
  28. Setting the root password ensures that nobody can log into the MySQL
  29. root user without the proper authorisation.
  30. Set root password? [Y/n] Y
  31. New password:
  32. Re-enter new password:
  33. Sorry, passwords do not match.
  34. New password:
  35. Re-enter new password:
  36. Password updated successfully!
  37. Reloading privilege tables..
  38. ... Success!
  39. By default, a MySQL installation has an anonymous user, allowing anyone
  40. to log into MySQL without having to have a user account created for
  41. them. This is intended only for testing, and to make the installation
  42. go a bit smoother. You should remove them before moving into a
  43. production environment.
  44. Remove anonymous users? [Y/n] Y
  45. ... Success!
  46. Normally, root should only be allowed to connect from 'localhost'. This
  47. ensures that someone cannot guess at the root password from the network.
  48. Disallow root login remotely? [Y/n] n
  49. ... skipping.
  50. By default, MySQL comes with a database named 'test' that anyone can
  51. access. This is also intended only for testing, and should be removed
  52. before moving into a production environment.
  53. Remove test database and access to it? [Y/n] n
  54. ... skipping.
  55. Reloading the privilege tables will ensure that all changes made so far
  56. will take effect immediately.
  57. Reload privilege tables now? [Y/n] Y
  58. ... Success!
  59. Cleaning up...
  60. All done! If you've completed all of the above steps, your MySQL
  61. installation should now be secure.
  62. Thanks for using MySQL!
  63. [root@hadoop05 mysql]#

测试连接

  1. [root@hadoop05 mysql]# mysql -u root -proot
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 7
  4. Server version: 5.1.73 MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> show databases;
  11. +--------------------+
  12. | Database |
  13. +--------------------+
  14. | information_schema |
  15. | mysql |
  16. | test |
  17. +--------------------+
  18. 3 rows in set (0.00 sec)
  19. mysql> use mysql;
  20. Reading table information for completion of table and column names
  21. You can turn off this feature to get a quicker startup with -A
  22. Database changed
  23. mysql> show tables;
  24. +---------------------------+
  25. | Tables_in_mysql |
  26. +---------------------------+
  27. | columns_priv |
  28. | db |
  29. | event |
  30. | func |
  31. | general_log |
  32. | help_category |
  33. | help_keyword |
  34. | help_relation |
  35. | help_topic |
  36. | host |
  37. | ndb_binlog_index |
  38. | plugin |
  39. | proc |
  40. | procs_priv |
  41. | servers |
  42. | slow_log |
  43. | tables_priv |
  44. | time_zone |
  45. | time_zone_leap_second |
  46. | time_zone_name |
  47. | time_zone_transition |
  48. | time_zone_transition_type |
  49. | user |
  50. +---------------------------+
  51. 23 rows in set (0.00 sec)
  52. mysql>

三、mysql授权

  1. GRANT ALL PRIVILEGES ON hive.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
  2. FLUSH PRIVILEGES;
  3. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
  4. FLUSH PRIVILEGES;

操作

  1. [root@hadoop05 mysql]# mysql -u root -proot
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 9
  4. Server version: 5.1.73 MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> use mysql;
  11. Reading table information for completion of table and column names
  12. You can turn off this feature to get a quicker startup with -A
  13. Database changed
  14. mysql> show tables;
  15. +---------------------------+
  16. | Tables_in_mysql |
  17. +---------------------------+
  18. | columns_priv |
  19. | db |
  20. | event |
  21. | func |
  22. | general_log |
  23. | help_category |
  24. | help_keyword |
  25. | help_relation |
  26. | help_topic |
  27. | host |
  28. | ndb_binlog_index |
  29. | plugin |
  30. | proc |
  31. | procs_priv |
  32. | servers |
  33. | slow_log |
  34. | tables_priv |
  35. | time_zone |
  36. | time_zone_leap_second |
  37. | time_zone_name |
  38. | time_zone_transition |
  39. | time_zone_transition_type |
  40. | user |
  41. +---------------------------+
  42. 23 rows in set (0.00 sec)
  43. mysql> select * from user
  44. -> ;
  45. +-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
  46. | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections |
  47. +-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
  48. | localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 |
  49. | hadoop05 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 |
  50. | 127.0.0.1 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 |
  51. +-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
  52. 3 rows in set (0.00 sec)
  53. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
  54. Query OK, 0 rows affected (0.00 sec)
  55. mysql> FLUSH PRIVILEGES;
  56. Query OK, 0 rows affected (0.00 sec)
  57. mysql>

相关文章

最新文章

更多