您好,登錄后才能下訂單哦!
小編給大家分享一下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如何部署”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。