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

How to deploy MySQL

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

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to deploy MySQL, I hope you will gain something after reading this article. Let's discuss it together.

1.Download

[root@ruozehadoop000 ~] # cd / usr/local

# Select the mysql package of win7

[root@ruozehadoop000 local] # rz Import package

2.Check isnot install

[root@ruozehadoop000 local] # ps-ef | grep mysqld

Root 2493 2423 0 19:48 pts/3 00:00:00 grep mysqld

[root@ruozehadoop000 local] # rpm-qa | grep-I mysql

3.tar and mv

[root@ruozehadoop000 local] # tar-xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz decompression

[root@ruozehadoop000 local] # mv mysql-5.6.23-linux-glibc2.5-x86_64 MySQL renamed

4.Create group and user

[root@ruozehadoop000 local] # groupadd-g 101 dba create dba group

[root@ruozehadoop000 local] # useradd-u 514-g dba-G root-d / usr/local/mysql mysqladmin create mysqladmin users, add uid,gid and groups and home directories.

Why create mysqladmin/dba?

1) A user only applies to one component

Important:copy environment variable configuration file to the home directory of the mysqladmin user

Configure personal environment variables for the following steps

[root@ruozehadoop000 local] # cp / etc/skel/.* / usr/local/mysql copy environment variables to home directory

5.Create / etc/my.cnf

[root@sht-sgmhadoopnn-01 ~] # vi / etc/my.cnf configuration cnf file

[client]

Port = 3306

Socket = / usr/local/mysql/data/mysql.sock

[mysqld]

Port = 3306

Socket = / usr/local/mysql/data/mysql.sock

Skip-external-locking

Key_buffer_size = 256m

Sort_buffer_size = 2m

Read_buffer_size = 2m

Read_rnd_buffer_size = 4m

Query_cache_size= 32M

Max_allowed_packet = 16m

Myisam_sort_buffer_size=128M

Tmp_table_size=32M

Table_open_cache = 512

Thread_cache_size = 8

Wait_timeout = 86400

Interactive_timeout = 86400

Max_connections = 600,

# Try number of CPU's*2 for thread_concurrency

Thread_concurrency = 32

# isolation level and default engine

Default-storage-engine = INNODB

Transaction-isolation = READ-COMMITTED

Server-id = 1

Basedir = / usr/local/mysql

Datadir = / usr/local/mysql/data

Pid-file = / usr/local/mysql/data/hostname.pid

# open performance schema

Log-warnings

Sysdate-is-now

Binlog_format = MIXED

Log_bin_trust_function_creators=1

Log-error = / usr/local/mysql/data/hostname.err

Log-bin=/usr/local/mysql/arch/mysql-bin

# other logs

# general_log = 1

# general_log_file = / usr/local/mysql/data/general_log.err

# slow_query_log=1

# slow_query_log_file=/usr/local/mysql/data/slow_log.err

# for replication slave

# log-slave-updates

# sync_binlog = 1

# for innodb options

Innodb_data_home_dir = / usr/local/mysql/data/

Innodb_data_file_path = ibdata1:500M:autoextend

Innodb_log_group_home_dir = / usr/local/mysql/arch

Innodb_log_files_in_group = 2

Innodb_log_file_size = 200m

Innodb_buffer_pool_size = 2048m

Innodb_additional_mem_pool_size = 50m

Innodb_log_buffer_size = 16m

Innodb_lock_wait_timeout = 100

# innodb_thread_concurrency = 0

Innodb_flush_log_at_trx_commit = 1

Innodb_locks_unsafe_for_binlog=1

# innodb io features: add for mysql5.5.8

Performance_schema

Innodb_read_io_threads=4

Innodb-write-io-threads=4

Innodb-io-capacity=200

# purge threads change default (0) to 1 for purge

Innodb_purge_threads=1

Innodb_use_native_aio=on

# case-sensitive file names and separate tablespace

Innodb_file_per_table = 1

Lower_case_table_names=1

[mysqldump]

Quick

Max_allowed_packet = 16m

[mysql]

No-auto-rehash

[mysqlhotcopy]

Interactive-timeout

[myisamchk]

Key_buffer_size = 256m

Sort_buffer_size = 256m

Read_buffer = 2m

Write_buffer = 2m

6.chown and chmod privileges and try first install

[root@ruozehadoop000 local] # chown mysqladmin:dba / etc/my.cnf modifies my.cnf users and user groups

[root@ruozehadoop000 local] # chmod 640 / etc/my.cnf modify its permissions

[root@ruozehadoop000 local] # chown-R mysqladmin:dba / usr/local/MySQL modify the users and user groups of the MySQL folder

[root@ruozehadoop000 local] # chmod-R 755 / usr/local/mysql modify its permissions

[root@ruozehadoop000 local] # su-mysqladmin enters mysqladmin users

[mysqladmin@ruozehadoop000 ~] $mkdir arch create arch folder

Installation

[mysqladmin@ruozehadoop000] $scripts/mysql_install_db-- user=mysqladmin-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data

7.Configure mysql service and boot auto start

[root@ruozehadoop000 ~] # cd / usr/local/mysql

# copy the service file to init.d and rename it to mysql

[root@ruozehadoop000 mysql] # cp support-files/mysql.server / etc/rc.d/init.d/mysql

# Grant executable permissions

[root@ruozehadoop000 mysql] # chmod + x / etc/rc.d/init.d/mysql

# deleting a service

[root@ruozehadoop000 mysql] # chkconfig-- del mysql

# add Services

[root@ruozehadoop000 mysql] # chkconfig-- add mysql

[root@ruozehadoop000 mysql] # chkconfig-- level 345 mysql on

8.Start mysql and to view process and listening

[root@ruozehadoop000 mysql] # su-mysqladmin

[mysqladmin@ruozehadoop000 ~] $pwd

/ usr/local/mysql

[mysqladmin@ruozehadoop000 ~] $rm-rf my.cnf delete files with the same name to avoid confusion

[mysqladmin@ruozehadoop000 ~] $bin/mysqld_safe &

Don't forget, press enter

[mysqladmin@ruozehadoop000 ~] $ps-ef | grep mysqld to view the process of mysqld

[mysqladmin@ruozehadoop000 ~] $netstat-tulnp | grep MySQL to check the port number

[root@ruozehadoop000 local] # service mysql status to view the status of mysql

9.Login mysql

[mysqladmin@ruozehadoop000 ~] $mysql directly enter one empty account and empty password

[mysqladmin@ruozehadoop000 ~] $mysql-uroot-p enter directly 2 times root empty password

Mysql > show databases; View the database

10.Update password and Purge user

Mysql > use mysql

Database changed

Mysql > select user,host,password from user; View users

Mysql > update user set password=password ('123456') where user='root'; changes the user's password

Mysql > delete from user where user=''; delete the specified user

Mysql > flush privileges; refresh permissions

11.Configure .bash _ profile

[mysqladmin@sht-sgmhadoopnn-01 ~] $cat .bash _ profile modifies the environment variable

Export MYSQL_BASE=/usr/local/mysql

Export PATH=$ {MYSQL_BASE} / bin:$PATH

PS1= `uname-n` ":"'$USER' ":"'$PWD' ": >"; export PS1

After reading this article, I believe you have some understanding of "how to deploy MySQL". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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: 0

*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