Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Handouts for customizing the installation path of mysql-5.5.56 version

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the custom mysql-5.5.56 version of the installation path handout, I hope you can supplement and update some knowledge, if there are other questions you need to know, you can continue to follow my updated article in the industry information.

Mysql-5.5.56 version (binary package installation)-Custom installation path

Installation path: / application/mysql-5.5.56

1. Prepare mysql dependencies in advance

Libaio

Yum install-y libaio

Create a user mysql and execute mysqluseradd-s / bin/false-M mysql as that user

Download the mysql binary package and extract cd / toolswget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gztar-zxf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz-C / application/

Change to the / application directory, shorten the mysql folder name, and make a soft link to the mysql directory cd / application/mv mysql-5.5.56-linux-glibc2.5-x86_64/ mysql-5.5.56ln-s mysql-5.5.56/ mysql

Recursively set the group and user chown-R mysql:mysql mysql-5.5.56/ of the mysql directory

Operation cd mysql in 2.mysql directory

Initialize the database

A data directory is generated within the mysql directory, where the database is stored

. / scripts/mysql_install_db-- basedir=/application/mysql-- datadir=/application/mysql/data/-- user=mysql

Change the user and group chown-R root .chown-R mysql data

Except that the user of the data directory under the mysql directory remains the same, the user of all other files is changed to root

Copy the configuration file cp support-files/my-medium.cnf / etc/my.cnf

Copy the configuration file of mysql to my.cnf in the / etc/ directory

Modify the configuration file sed-I 28isubscription logcolor errorUniplicationApplicationUniqlUniqlUniDATAGUBE mysqld.error' / etc/my.cnf

A line is inserted in the configuration file to log configuration errors

/ etc/my.cnf Content:

# Example MySQL config file for medium systems.## This is for a system with little memory (32m-64m) where MySQL plays# an important part, or systems up to 128m where MySQL is used together with# other programs (such as a web server) # # MySQL programs look for option files in a set of# locations which depend on the deployment platform.# You can copy this option file to one of those# locations. For information about these locations, see:# http://dev.mysql.com/doc/mysql/en/option-files.html## In this file, you can use all long options that a program supports.# If you want to know which options a program supports, run the program# with the "--help" option. # The following options will be passed to all MySQL clients [client] # password = your_passwordport = 3306socket = / tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306log-error=/application/mysql/data/mysqld.errorsocket = / tmp/mysql.sockskip-external-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8m # Don't listen on a TCP/IP port at all. This can be a security enhancement # if all processes that need to connect to mysqld run on the same host.# All interaction with mysqld must be made via Unix sockets or named pipes.# Note that using this option without enabling named pipes on Windows# (via the "enable-named-pipe" option) will render mysqld uselessness conversation networking # Replication Master Server (default) # binary logging is required for replicationlog-bin=mysql-bin # binary logging format-mixed recommendedbinlog_format=mixed # required unique id between 1 and 2 ^ 32-floor defaults to 1 if master-host is not set# but will not function As a master if omittedserver-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave You can choose between# two methods: # # 1) Use the CHANGE MASTER TO command (fully described in our manual)-# the syntax is:## CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,# MASTER_USER=, MASTER_PASSWORD= # # where you replace, by quoted strings and# by the master's port number (3306 by default). # # Example:## CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,# MASTER_USER='joe', MASTER_PASSWORD='secret';## OR## 2) Set the variables below. However, in case you choose this method, then# start replication for the first time (even unsuccessfully, for example# if you mistyped the password in master-password and the slave fails to# connect), the slave will create a master.info file, and any later# change in this file to the variables' values below will be ignored and# overridden by the content of the master.info file, unless you shutdown# the slave server, delete master.info and restart the slaver server.# For that reason You may want to leave the lines below untouched# (commented) and instead use CHANGE MASTER TO (see above) # # required unique id between 2 and 2 ^ 32-and different from the master) # defaults to 2 if master-host is set# but will not function as a slave if omitted#server-id = 2percent # The replication master for this slave-required#master-host = # # The username the slave will use for authentication when connecting# to the master- required#master-user = # # The password the slave will authenticate with when connecting to# the master- required#master-password = # # The port the master is listening on.# optional-defaults to 3306#master-port = # # binary logging-not required for slaves But recommended#log-bin=mysql-bin # Uncomment the following if you are using InnoDB tables#innodb_data_home_dir = / usr/local/mysql/data#innodb_data_file_path = ibdata1:10M:autoextend#innodb_log_group_home_dir = / usr/local/mysql/data# You can set.. _ buffer_pool_size up to 50-80% # of RAM but beware of setting memory usage too high#innodb_buffer_pool_size = 16M#innodb_additional_mem_pool_size = 2M# Set.. _ log_file_size to 25% of buffer pool size#innodb_log_file_size = 5M#innodb_log_buffer_size = 8M#innodb_flush_log_at_trx_commit = 1#innodb_lock_wait_timeout = 50 [mysqldump] quickmax_allowed_packet = 16m [mysql] no-auto-rehash# Remove the next comment character if you are not familiar with SQL#safe-updates [myisamchk] key_buffer_size = 20Msort_buffer_size = 20Mread_buffer = 2Mwrite_buffer = 2m [mysqlhotcopy] interactive-timeout

Copy the startup program cp support-files/mysql.server / etc/init.d/mysql

Copy the startup program of mysql to the / etc/init.d/ directory to start the program

Edit the startup file and configure the startup directory

Method 1:

The idea is to assign values to the variables provided by the configuration file. It's troublesome.

Sed-I': a *

It is equivalent to putting 45 and 46 lines

Replace basedir=datadir=mysqld_pid_file_path= with basedir=/application/mysqldatadir=/application/mysql/datamysqld_pid_file_path=/application/mysql/data/mysql.pid

Method 2 (recommended):

The idea is to directly replace the default address of the script (/ usr/local/mysql) with a custom path (/ application/mysql), so you don't have to assign a value to the variable

Sed-I-I

After the installation of mysql is completed, you can start normally.

3. Post-end command to create soft links

Create a soft link mysql command to the directory of the environment variable, so that the user can find the corresponding command in the variable

Ln-s / application/mysql/bin/* / usr/local/sbin

Set and modify passwords

Set the password for the first time:

Mysqladmin-upright 'password''

Example:

Mysqladmin-ubiquitous root 'password' PassWord'

Change the password later:

Mysqladmin-upright'- paired 'password''

Example:

Mysqladmin-upright root'-paired Password 'password' NewPassWord'

Log in to mysql [root@www mysql] # mysql-ubiquitous root'-p'PassWord'Welcome to the MySQL monitor. Commands end with; or\ g....mysql > # successfully log in to the mysql console [root@www mysql] # mysql-uroot-pPassWordWelcome to the MySQL monitor. Commands end with; or\ g....mysql > # successfully log in to the mysql console [root@www mysql] # mysql-uplink root'- pEnter password: # enter the user's password here. Commands end with; or\ g....mysql > # successfully log in to the mysql console [root@www mysql] # mysql-uroot-pEnter password: # enter the user's password Welcome to the MySQL monitor here. Commands end with; or\ g....mysql > # successfully logged in to the mysql console

Type quit or Ctrl + d to exit the mysql environment mysql > quitBye [root@www mysql] # ormysql > ^ DBye [root@www mysql] #

4. Common commands enter mysqlmysql-upright root'-p'PassWord'mysql-uroot-pPassWord mysql-upright root'-pmysql-uroot-p

Start mysqlservice mysql start

Stop mysqlservice mysql stop

Restart mysqlservice mysql restart

Read the above on the custom mysql-5.5.56 version of the installation path handout, I hope to give you some help in practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 205

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report