Chinaunix首页 | 论坛 | 博客
  • 博客访问: 227900
  • 博文数量: 70
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 440
  • 用 户 组: 普通用户
  • 注册时间: 2015-08-09 09:16
个人简介

淡泊以明志,宁静以致远。

文章分类

全部博文(70)

分类: LINUX

2017-11-25 22:40:16

  •  创建MySQL用户
#useradd mysql
#passwd mysql
#chmod u+w /etc/sudoers
#vi /etc/sudoers
mysql ALL=(ALL) ALL

 

  • 安装仓库

要使用yum 安装mysql,要使用mysql的yum仓库,先从官网下载适合你系统的仓库
http://dev.mysql.com/downloads/repo/yum/
然后安装一下这个仓库列表


	

wget
rpm -ivh mysql-community-release-el6-5.noarch.rpm

或:
# yum install http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm

 

  • 选择版本

查看可安装的mysql版本

[mysql@mysql-1 ~]$ yum repolist enabled | grep "mysql.*-community.*" mysql-connectors-community MySQL Connectors Community 21 mysql-tools-community MySQL Tools Community 35 mysql57-community MySQL 5.7 Community Server 82

 

如果我们要选择版本,可以先执行下面这个命令查看一下有哪些版本

[mysql@mysql-1 ~]$ yum repolist all | grep mysql


选择版本,启用5.6版本的,禁用5.7版本子仓库

[mysql@mysql-1 ~]$ sudo yum-config-manager --enable mysql56-community
[mysql@mysql-1 ~]$ sudo yum-config-manager --disable mysql57-community

或者
编辑/etc/yum.repos.d/mysql-community.repo文件
enabled=0 表示禁用
比如要安装5.7版本的mysql,要确定5.6的enabled=0,5.7的enabled=1,一次保证只启用一个子仓库

 

查看可安装的mysql版本

[mysql@mysql-1 ~]$ yum repolist enabled | grep "mysql.*-community.*" mysql-connectors-community MySQL Connectors Community 21 mysql-tools-community MySQL Tools Community 35 mysql56-community MySQL 5.6 Community Server 248

 

  • 安装
[mysql@mysql-1 ~]$ sudo yum install mysql-community-server
  •  启动数据库

点击(此处)折叠或打开

  1. [root@mysql-1 mysql]# service mysqld strat
  2. 用法:/etc/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload}
  3. [root@mysql-1 mysql]# service mysqld start
  4. 初始化 MySQL 数据库: 2016-05-11 10:15:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  5. 2016-05-11 10:15:01 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30) starting as process 2843 ...
  6. 2016-05-11 10:15:01 2843 [Note] InnoDB: Using atomics to ref count buffer pool pages
  7. 2016-05-11 10:15:01 2843 [Note] InnoDB: The InnoDB memory heap is disabled
  8. 2016-05-11 10:15:01 2843 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  9. 2016-05-11 10:15:01 2843 [Note] InnoDB: Memory barrier is not used
  10. 2016-05-11 10:15:01 2843 [Note] InnoDB: Compressed tables use zlib 1.2.3
  11. 2016-05-11 10:15:01 2843 [Note] InnoDB: Using Linux native AIO
  12. 2016-05-11 10:15:01 2843 [Note] InnoDB: Using CPU crc32 instructions
  13. 2016-05-11 10:15:01 2843 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  14. 2016-05-11 10:15:01 2843 [Note] InnoDB: Completed initialization of buffer pool
  15. 2016-05-11 10:15:01 2843 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
  16. 2016-05-11 10:15:01 2843 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
  17. 2016-05-11 10:15:01 2843 [Note] InnoDB: Database physically writes the file full: wait...
  18. 2016-05-11 10:15:01 2843 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
  19. 2016-05-11 10:15:01 2843 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
  20. 2016-05-11 10:15:02 2843 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
  21. 2016-05-11 10:15:02 2843 [Warning] InnoDB: New log files created, LSN=45781
  22. 2016-05-11 10:15:02 2843 [Note] InnoDB: Doublewrite buffer not found: creating new
  23. 2016-05-11 10:15:02 2843 [Note] InnoDB: Doublewrite buffer created
  24. 2016-05-11 10:15:02 2843 [Note] InnoDB: 128 rollback segment(s) are active.
  25. 2016-05-11 10:15:02 2843 [Warning] InnoDB: Creating foreign key constraint system tables.
  26. 2016-05-11 10:15:02 2843 [Note] InnoDB: Foreign key constraint system tables created
  27. 2016-05-11 10:15:02 2843 [Note] InnoDB: Creating tablespace and datafile system tables.
  28. 2016-05-11 10:15:02 2843 [Note] InnoDB: Tablespace and datafile system tables created.
  29. 2016-05-11 10:15:02 2843 [Note] InnoDB: Waiting for purge to start
  30. 2016-05-11 10:15:02 2843 [Note] InnoDB: 5.6.30 started; log sequence number 0
  31. 2016-05-11 10:15:03 2843 [Note] Binlog end
  32. 2016-05-11 10:15:03 2843 [Note] InnoDB: FTS optimize thread exiting.
  33. 2016-05-11 10:15:03 2843 [Note] InnoDB: Starting shutdown...
  34. 2016-05-11 10:15:05 2843 [Note] InnoDB: Shutdown completed; log sequence number 1625977
  35. 2016-05-11 10:15:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  36. 2016-05-11 10:15:05 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30) starting as process 2866 ...
  37. 2016-05-11 10:15:05 2866 [Note] InnoDB: Using atomics to ref count buffer pool pages
  38. 2016-05-11 10:15:05 2866 [Note] InnoDB: The InnoDB memory heap is disabled
  39. 2016-05-11 10:15:05 2866 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  40. 2016-05-11 10:15:05 2866 [Note] InnoDB: Memory barrier is not used
  41. 2016-05-11 10:15:05 2866 [Note] InnoDB: Compressed tables use zlib 1.2.3
  42. 2016-05-11 10:15:05 2866 [Note] InnoDB: Using Linux native AIO
  43. 2016-05-11 10:15:05 2866 [Note] InnoDB: Using CPU crc32 instructions
  44. 2016-05-11 10:15:05 2866 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  45. 2016-05-11 10:15:05 2866 [Note] InnoDB: Completed initialization of buffer pool
  46. 2016-05-11 10:15:05 2866 [Note] InnoDB: Highest supported file format is Barracuda.
  47. 2016-05-11 10:15:05 2866 [Note] InnoDB: 128 rollback segment(s) are active.
  48. 2016-05-11 10:15:05 2866 [Note] InnoDB: Waiting for purge to start
  49. 2016-05-11 10:15:05 2866 [Note] InnoDB: 5.6.30 started; log sequence number 1625977
  50. 2016-05-11 10:15:06 2866 [Note] Binlog end
  51. 2016-05-11 10:15:06 2866 [Note] InnoDB: FTS optimize thread exiting.
  52. 2016-05-11 10:15:06 2866 [Note] InnoDB: Starting shutdown...
  53. 2016-05-11 10:15:07 2866 [Note] InnoDB: Shutdown completed; log sequence number 1625987
  54. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  55. To do so, start the server, then issue the following commands:
  56. /usr/bin/mysqladmin -u root password 'new-password'
  57. /usr/bin/mysqladmin -u root -h mysql-1 password 'new-password'
  58. Alternatively you can run:
  59. /usr/bin/mysql_secure_installation
  60. which will also give you the option of removing the test
  61. databases and anonymous user created by default. This is
  62. strongly recommended for production servers.
  63. See the manual for more instructions.
  64. Please report any problems at
  65. The latest information about MySQL is available on the web at
  66. Support MySQL by buying support/licenses at
  67. Note: new default config file not created.
  68. Please make sure your config file is current
  69. WARNING: Default config file /etc/my.cnf exists on the system
  70. This file will be read by default by the MySQL server
  71. If you do not want to use this, either remove it, or use the
  72. --defaults-file argument to mysqld_safe when starting the server
  73. [确定]
  74. 正在启动 mysqld: [确定]
  • 安全配置

点击(此处)折叠或打开

  1. [root@mysql-1 mysql]# /usr/bin/mysql_secure_installation
  2. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
  3. SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
  4. In order to log into MySQL to secure it, we'll need the current
  5. password for the root user. If you've just installed MySQL, and
  6. you haven't set the root password yet, the password will be blank,
  7. so you should just press enter here.
  8. Enter current password for root (enter for none): ----输入root密码(默认为空):
  9. OK, successfully used password, moving on...
  10. Setting the root password ensures that nobody can log into the MySQL
  11. root user without the proper authorisation.
  12. Set root password? [Y/n] y ----是否要修改root密码:
  13. New password:
  14. Re-enter new password:
  15. Password updated successfully!
  16. Reloading privilege tables..
  17. ... Success!
  18. By default, a MySQL installation has an anonymous user, allowing anyone
  19. to log into MySQL without having to have a user account created for
  20. them. This is intended only for testing, and to make the installation
  21. go a bit smoother. You should remove them before moving into a
  22. production environment.
  23. Remove anonymous users? [Y/n] y
  24. ... Success!
  25. Normally, root should only be allowed to connect from 'localhost'. This
  26. ensures that someone cannot guess at the root password from the network.
  27. Disallow root login remotely? [Y/n] y
  28. ... Success!
  29. By default, MySQL comes with a database named 'test' that anyone can
  30. access. This is also intended only for testing, and should be removed
  31. before moving into a production environment.
  32. Remove test database and access to it? [Y/n] n
  33. ... skipping.
  34. Reloading the privilege tables will ensure that all changes made so far
  35. will take effect immediately.
  36. Reload privilege tables now? [Y/n] y
  37. ... Success!
  38. All done! If you've completed all of the above steps, your MySQL
  39. installation should now be secure.
  40. Thanks for using MySQL!
  41. Cleaning up...
  42. [root@mysql-1 mysql]#
[root@mysql-1 mysql]#  service mysqld status
mysqld (pid 3097) 正在运行...

转载自:https://www.cnblogs.com/a3470194/p/5480911.html
阅读(1487) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~