共计 4820 个字符,预计需要花费 13 分钟才能阅读完成。
丸趣 TV 小编给大家分享一下 MySQL 如何部署,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
1.Download
[root@ruozehadoop000 ~]# cd /usr/local
# 选择 win7 的 mysql 软件包
[root@ruozehadoop000 local]# rz 导入软件包
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 解压
[root@ruozehadoop000 local]# mv mysql-5.6.23-linux-glibc2.5-x86_64 MySQL 改名
4.Create group and user
[root@ruozehadoop000 local]# groupadd -g 101 dba 创建 dba group
[root@ruozehadoop000 local]# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin 创建 mysqladmin 用户,添加 uid,gid 以及组和家目录。
为什么要创建 mysqladmin/dba?
1)一个用户只对一个组件
important:copy 环境变量配置文件至 mysqladmin 用户的 home 目录中,
为了以下步骤配置个人环境变量
[root@ruozehadoop000 local]# cp /etc/skel/.* /usr/local/mysql 复制环境变量到家目录
5.Create /etc/my.cnf(640)
[root@sht-sgmhadoopnn-01 ~]# vi /etc/my.cnf 配置 cnf 文件
[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 修改 my.cnf 的用户及用户组
[root@ruozehadoop000 local]# chmod 640 /etc/my.cnf 修改其权限
[root@ruozehadoop000 local]# chown -R mysqladmin:dba /usr/local/MySQL 修改 MySQL 文件夹的用户及用户组
[root@ruozehadoop000 local]# chmod -R 755 /usr/local/mysql 修改其权限
[root@ruozehadoop000 local]# su – mysqladmin 进入 mysqladmin 用户
[mysqladmin@ruozehadoop000 ~]$ mkdir arch 创建 arch 文件夹
安装
[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
# 将服务文件拷贝到 init.d 下,并重命名为 mysql
[root@ruozehadoop000 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
# 赋予可执行权限
[root@ruozehadoop000 mysql]# chmod +x /etc/rc.d/init.d/mysql
# 删除服务
[root@ruozehadoop000 mysql]# chkconfig –del mysql
# 添加服务
[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 删除同名文件避免混淆
[mysqladmin@ruozehadoop000 ~]$ bin/mysqld_safe
不要忘记,按回车键
[mysqladmin@ruozehadoop000 ~]$ ps -ef|grep mysqld 查看 mysqld 的进程
[mysqladmin@ruozehadoop000 ~]$ netstat -tulnp | grep MySQL 查看端口号
[root@ruozehadoop000 local]# service mysql status 查看 mysql 的状态
9.Login mysql
[mysqladmin@ruozehadoop000 ~]$ mysql 直接回车 1 次 空账号 空密码
[mysqladmin@ruozehadoop000 ~]$ mysql -uroot -p 直接回车 2 次 root 空密码
mysql show databases; 查看数据库
10.Update password and Purge user
mysql use mysql
Database changed
mysql select user,host,password from user; 查看用户
mysql update user set password=password(123456) where user= root 修改用户密码
mysql delete from user where user= 删除指定用户
mysql flush privileges; 刷新权限
11.Configure .bash_profile
[mysqladmin@sht-sgmhadoopnn-01 ~]$ cat .bash_profile 修改环境变量
export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
PS1=`uname -n` : $USER : $PWD : export PS1
看完了这篇文章,相信你对“MySQL 如何部署”有了一定的了解,如果想了解更多相关知识,欢迎关注丸趣 TV 行业资讯频道,感谢各位的阅读!