• 售前

  • 售后

热门帖子
入门百科

Mysql 5.5.56版本(二进制包安装)自界说安装路径步调记录

[复制链接]
123456806 显示全部楼层 发表于 2021-10-25 20:10:26 |阅读模式 打印 上一主题 下一主题
安装路径:/application/mysql-5.5.56
1.前期准备
mysql依靠
  1. libaio
  2. yum install -y libaio
复制代码
创建用户mysql,以该用户的身份执行mysql
  1. useradd -s /bin/false -M mysql
复制代码
下载mysql二进制包并解压
  1. cd /tools
  2. wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
  3. tar -zxf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz -C /application/
复制代码
切换到/application目录,将mysql文件夹名改短,给mysql目录做一个软链接
  1. cd /application/
  2. mv mysql-5.5.56-linux-glibc2.5-x86_64/ mysql-5.5.56
  3. ln -s mysql-5.5.56/ mysql
复制代码
递归设置mysql目录的所属组和所属用户
  1. chown -R mysql:mysql mysql-5.5.56/
复制代码
2.mysql目录内操作
  1. cd mysql
复制代码
初始化数据库
会在mysql目录内生成一个data目录,存放数据库的目录
  1. ./scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
复制代码
更改所属用户和组
  1. chown -R root .
  2. chown -R mysql data
复制代码
除了mysql目录下的data目录所属用户不变,其他全部文件的所属用户改为root
拷贝设置文件
  1. cp support-files/my-medium.cnf /etc/my.cnf
复制代码
将mysql的设置文件拷贝为/etc/目录下的my.cnf
修改设置文件
  1. sed -i 28i'log-error=/application/mysql/data/mysqld.error' /etc/my.cnf
复制代码
在设置文件插入了一行,举行设置错误日志
  1. /etc/my.cnf Content:
  2. # Example MySQL config file for medium systems.
  3. #
  4. # This is for a system with little memory (32M - 64M) where MySQL plays
  5. # an important part, or systems up to 128M where MySQL is used together with
  6. # other programs (such as a web server)
  7. #
  8. # MySQL programs look for option files in a set of
  9. # locations which depend on the deployment platform.
  10. # You can copy this option file to one of those
  11. # locations. For information about these locations, see:
  12. # http://dev.mysql.com/doc/mysql/en/option-files.html
  13. #
  14. # In this file, you can use all long options that a program supports.
  15. # If you want to know which options a program supports, run the program
  16. # with the "--help" option.
  17. # The following options will be passed to all MySQL clients
  18. [client]
  19. #password = your_password
  20. port = 3306
  21. socket = /tmp/mysql.sock
  22. # Here follows entries for some specific programs
  23. # The MySQL server
  24. [mysqld]
  25. port = 3306
  26. log-error=/application/mysql/data/mysqld.error
  27. socket = /tmp/mysql.sock
  28. skip-external-locking
  29. key_buffer_size = 16M
  30. max_allowed_packet = 1M
  31. table_open_cache = 64
  32. sort_buffer_size = 512K
  33. net_buffer_length = 8K
  34. read_buffer_size = 256K
  35. read_rnd_buffer_size = 512K
  36. myisam_sort_buffer_size = 8M
  37. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  38. # if all processes that need to connect to mysqld run on the same host.
  39. # All interaction with mysqld must be made via Unix sockets or named pipes.
  40. # Note that using this option without enabling named pipes on Windows
  41. # (via the "enable-named-pipe" option) will render mysqld useless!
  42. #
  43. #skip-networking
  44. # Replication Master Server (default)
  45. # binary logging is required for replication
  46. log-bin=mysql-bin
  47. # binary logging format - mixed recommended
  48. binlog_format=mixed
  49. # required unique id between 1 and 2^32 - 1
  50. # defaults to 1 if master-host is not set
  51. # but will not function as a master if omitted
  52. server-id = 1
  53. # Replication Slave (comment out master section to use this)
  54. #
  55. # To configure this host as a replication slave, you can choose between
  56. # two methods :
  57. #
  58. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  59. # the syntax is:
  60. #
  61. # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
  62. # MASTER_USER=, MASTER_PASSWORD= ;
  63. #
  64. # where you replace , , by quoted strings and
  65. # by the master's port number (3306 by default).
  66. #
  67. # Example:
  68. #
  69. # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  70. # MASTER_USER='joe', MASTER_PASSWORD='secret';
  71. #
  72. # OR
  73. #
  74. # 2) Set the variables below. However, in case you choose this method, then
  75. # start replication for the first time (even unsuccessfully, for example
  76. # if you mistyped the password in master-password and the slave fails to
  77. # connect), the slave will create a master.info file, and any later
  78. # change in this file to the variables' values below will be ignored and
  79. # overridden by the content of the master.info file, unless you shutdown
  80. # the slave server, delete master.info and restart the slaver server.
  81. # For that reason, you may want to leave the lines below untouched
  82. # (commented) and instead use CHANGE MASTER TO (see above)
  83. #
  84. # required unique id between 2 and 2^32 - 1
  85. # (and different from the master)
  86. # defaults to 2 if master-host is set
  87. # but will not function as a slave if omitted
  88. #server-id = 2
  89. #
  90. # The replication master for this slave - required
  91. #master-host =
  92. #
  93. # The username the slave will use for authentication when connecting
  94. # to the master - required
  95. #master-user =
  96. #
  97. # The password the slave will authenticate with when connecting to
  98. # the master - required
  99. #master-password =
  100. #
  101. # The port the master is listening on.
  102. # optional - defaults to 3306
  103. #master-port =
  104. #
  105. # binary logging - not required for slaves, but recommended
  106. #log-bin=mysql-bin
  107. # Uncomment the following if you are using InnoDB tables
  108. #innodb_data_home_dir = /usr/local/mysql/data
  109. #innodb_data_file_path = ibdata1:10M:autoextend
  110. #innodb_log_group_home_dir = /usr/local/mysql/data
  111. # You can set .._buffer_pool_size up to 50 - 80 %
  112. # of RAM but beware of setting memory usage too high
  113. #innodb_buffer_pool_size = 16M
  114. #innodb_additional_mem_pool_size = 2M
  115. # Set .._log_file_size to 25 % of buffer pool size
  116. #innodb_log_file_size = 5M
  117. #innodb_log_buffer_size = 8M
  118. #innodb_flush_log_at_trx_commit = 1
  119. #innodb_lock_wait_timeout = 50
  120. [mysqldump]
  121. quick
  122. max_allowed_packet = 16M
  123. [mysql]
  124. no-auto-rehash
  125. # Remove the next comment character if you are not familiar with SQL
  126. #safe-updates
  127. [myisamchk]
  128. key_buffer_size = 20M
  129. sort_buffer_size = 20M
  130. read_buffer = 2M
  131. write_buffer = 2M
  132. [mysqlhotcopy]
  133. interactive-timeout
复制代码
拷贝启动步伐
  1. cp support-files/mysql.server /etc/init.d/mysql
复制代码
将mysql的启动步伐拷贝到/etc/init.d/目录下,以便启动步伐
编辑启动文件,设置启动目录
方法一:
思路是给设置文件提供的变量举行赋值。较麻烦。
  1. sed -i ':a;N;$!ba;s/basedir=\ndatadir=/basedir=\/application\/mysql\ndatadir=\/application\/mysql\/data/g' /etc/init.d/mysql
  2. sed -i ':a;N;$!ba;s/mysqld_pid_file_path=\n/mysqld_pid_file_path=\/application\/mysql\/data\/mysqld.pid\n/g' /etc/init.d/mysql
复制代码
等价于将45、46两行
  1. basedir=
  2. datadir=
  3. mysqld_pid_file_path=
复制代码
替换成
  1. basedir=/application/mysql
  2. datadir=/application/mysql/data
  3. mysqld_pid_file_path=/application/mysql/data/mysql.pid
复制代码
方法二(推荐):
思路是将脚本的默认地点(/usr/local/mysql)直接替换成自界说路径(/application/mysql),便不消给变量赋值
  1. sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysql
复制代码
到这里mysql安装完成可以正常启动
3.后期结尾
下令创建软链接
将mysql下令创建软链接到情况变量的目录,使用户可以在变量找到相应的下令
  1. ln -s /application/mysql/bin/* /usr/local/sbin
复制代码
设置与修改暗码
第一次设置暗码:
  1. mysqladmin -u'' password ''
复制代码
例子:
  1. mysqladmin -u'root' password 'PassWord'
复制代码
以后修改暗码:
  1. mysqladmin -u'' -p'' password ''
复制代码
例子:
  1. mysqladmin -u'root' -p'PassWord' password 'NewPassWord'
复制代码
登录mysql
  1. $ mysql -u'root' -p'PassWord'
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. ...
  4. mysql> #成功登陆到mysql控制台
  5. $ mysql -uroot -pPassWord
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. ...
  8. mysql> #成功登陆到mysql控制台
  9. $ mysql -u'root' -p
  10. Enter password: #这里输入用户的密码
  11. Welcome to the MySQL monitor. Commands end with ; or \g.
  12. ...
复制代码
mysql> #乐成登岸到mysql控制台
  1. $ mysql -uroot -p
  2. Enter password: #这里输入用户的密码
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. ...
复制代码
mysql> #乐成登岸到mysql控制台
键入quit或Ctrl + d退出mysql情况
  1. mysql> quit
  2. Bye
  3. [root@www mysql]#
  4. or
  5. mysql> ^DBye
  6. [root@www mysql]#
复制代码
4.常用下令
进入mysql
  1. mysql -u'root' -p'PassWord'
  2. mysql -uroot -pPassWord
  3. mysql -u'root' -p
  4. mysql -uroot -p
复制代码
启动mysql
  1. service mysql start
复制代码
制止mysql
  1. service mysql stop
复制代码
重启mysql
  1. service mysql restart
复制代码
以上所述是小编给各人介绍的Mysql 5.5.56版本(二进制包安装)自界说安装路径步骤记录,盼望对各人有所资助,假如各人有任何疑问请给我留言,小编会及时回复各人的。在此也非常感谢各人对草根技能分享网站的支持!

帖子地址: 

回复

使用道具 举报

分享
推广
火星云矿 | 预约S19Pro,享500抵1000!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

草根技术分享(草根吧)是全球知名中文IT技术交流平台,创建于2021年,包含原创博客、精品问答、职业培训、技术社区、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区。
  • 官方手机版

  • 微信公众号

  • 商务合作