[root@hadoop001 ~]# rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 删除原有的里屋包
[root@hadoop001 ~]# rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64 有依赖关系,加上--nodeps
[root@hadoop001 ~]# yum search mysql 搜索
[root@hadoop001 ~]# yum install mysql-server.x86_64 mysql.x86_64 安装
[root@hadoop001 ~]# service mysqld start 启动
Starting mysqld: [ OK ]
[root@hadoop001 ~]# mysql 进入
[root@hadoop001 ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@hadoop001 ~]# ps -ef|grep mysql
root 9441 1 0 23:08 pts/2 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 9527 9441 0 23:08 pts/2 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/hadoop001.err --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 9555 8017 0 23:11 pts/2 00:00:00 grep mysql
[root@hadoop001 ~]# mysql --socket=/var/lib/mysql/mysql.sock
mysql>
mysql>
1.Upload tar
rz 上传
ll 查看
[root@hadoop001 ~]# mv mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz /usr/local 移动
[root@hadoop001 ~]# cd /usr/local
[root@hadoop001 local]# ll
total 304512
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
2.Check isnot install 查看别人是否部署
[root@hadoop001 local]# ps -ef|grep mysald 是否有残留进程
root 32382 30576 0 16:15 pts/0 00:00:00 grep mysald
[root@hadoop001 local]# rpm -qa |grep -i mysql
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
mysql-5.1.73-8.el6_8.x86_64
[root@hadoop001 local]#
3tar and mv and 软连接
tar xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz 解压
[root@hadoop001 local]# mv mysql-5.6.23-linux-glibc2.5-x86_64 mysql 软连接不需要重命名
[root@hadoop001 local]# ll
total 304516
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
drwxr-xr-x 13 root root 4096 Jun 29 16:23 mysql
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
[root@hadoop001 local]# ln -s mysql-5.6.23-linux-glibc2.5-x86_64 mysql 软连接
[root@hadoop001 local]# ll
total 304516
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
lrwxrwxrwx 1 root root 34 Jun 29 16:31 mysql -> mysql-5.6.23-linux-glibc2.5-x86_64
drwxr-xr-x 13 root root 4096 Jun 29 16:23 mysql-5.6.23-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
4.Create group and user
[root@hadoop001 local]# groupadd -g 101 dba
[root@hadoop001 local]# useradd -u 521 -g dba -G root -d /usr/local/mysql mysqladmin
[root@hadoop001 local]# id mysqladmin
uid=521(mysqladmin) gid=101(dba) groups=101(dba),0(root)
生产上是可切到 su - mysqladmin 的账户
[root@hadoop001 local]# passwd mysqladmin 设置密码
Changing password for user mysqladmin.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
##未做,但需知道此种方法
## if user mysqladmin is existing,please execute the following command of usermod.
##[root@sht-sgmhadoopnn-01 local]# usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin #
[root@hadoop001 local]# su - mysqladmin
-bash-4.1$
-bash-4.1$ 样式丢失
co 环境变量配置文件至mysqladmin用户的home目录中,以下步骤配置个人环境变量
-bash-4.1$ cp /etc/skel/.* ./
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: cannot create regular file `./.bash_logout': Permission denied
cp: cannot create regular file `./.bash_profile': Permission denied
cp: cannot create regular file `./.bashrc': Permission denied 报错权限受限 切到有权限的用户做
-bash-4.1$
[root@hadoop001 local]# cp /etc/skel/.* /usr/local/mysql/ 进行配置
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
[root@hadoop001 local]# su - mysqladmin
[mysqladmin@hadoop001 ~]$
5.Create /etc/my.cnf(640) rw-r-----
##defualt start: /etc/my.cnf->/etc/mysql/my.cnf->SYSCONFDIR/my.cnf->$MYSQL_HOME/my.cnf-> --defaults-extra-file->~/my.cnf
[root@hadoop001 local]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@hadoop001 local]# cp /etc/my.cnf /etc/my.cnf20190629 养成好习惯复制一份
vi my.cnf 先小写d大写G清空 然后配置以下内容
[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 #生产上这里是需要调整的,正常调成8个G到12个G够用了
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@hadoop001 local]# chown mysqladmin:dba /etc/my.cnf
[root@hadoop001 local]# chmod 640 /etc/my.cnf
[root@hadoop001 etc]# ll my.cnf
-rw-r----- 1 mysqladmin dba 2218 Jun 29 17:20 my.cnf
##只修改软连接
[root@hadoop001 local]# chown -R mysqladmin:dba /usr/local/mysql
[root@hadoop001 local]# chmod -R 755 /usr/local/mysql/*
[root@hadoop001 local]# chmod -R 755 /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64
[root@hadoop001 local]# ll
total 304516
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
lrwxrwxrwx 1 mysqladmin dba 34 Jun 29 16:31 mysql -> mysql-5.6.23-linux-glibc2.5-x86_64
drwxr-xr-x 13 root root 4096 Jun 29 17:02 mysql-5.6.23-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
[root@hadoop001 local]# cd mysql
[root@hadoop001 mysql]# ll
total 168
drwxr-xr-x 2 root root 4096 Jun 29 16:23 bin
-rwxr-xr-x 1 7161 wheel 17987 Jan 19 2015 COPYING
drwxr-xr-x 3 root root 4096 Jun 29 16:22 data
drwxr-xr-x 2 root root 4096 Jun 29 16:23 docs
drwxr-xr-x 3 root root 4096 Jun 29 16:23 include
-rwxr-xr-x 1 7161 wheel 102315 Jan 19 2015 INSTALL-BINARY
drwxr-xr-x 3 root root 4096 Jun 29 16:22 lib
drwxr-xr-x 4 root root 4096 Jun 29 16:23 man
drwxr-xr-x 10 root root 4096 Jun 29 16:23 mysql-test
-rwxr-xr-x 1 7161 wheel 2496 Jan 19 2015 README
drwxr-xr-x 2 root root 4096 Jun 29 16:22 scripts
drwxr-xr-x 28 root root 4096 Jun 29 16:22 share
drwxr-xr-x 4 root root 4096 Jun 29 16:23 sql-bench
drwxr-xr-x 2 root root 4096 Jun 29 16:22 support-files
[root@hadoop001 mysql]#
关于文件夹的修改 修改完成后 一定要cd进去 ll再看一下里面的是否修改,未修改则进行修改
##加*代表所有的
[root@hadoop001 local]# chown -R mysqladmin:dba /usr/local/mysql/*
[root@hadoop001 local]# ll
total 304516
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
lrwxrwxrwx 1 mysqladmin dba 34 Jun 29 16:31 mysql -> mysql-5.6.23-linux-glibc2.5-x86_64
drwxr-xr-x 13 root root 4096 Jun 29 17:02 mysql-5.6.23-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
[root@hadoop001 local]# cd mysql
[root@hadoop001 mysql]# ll
total 168
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 bin
-rwxr-xr-x 1 mysqladmin dba 17987 Jan 19 2015 COPYING
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:22 data
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 docs
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:23 include
-rwxr-xr-x 1 mysqladmin dba 102315 Jan 19 2015 INSTALL-BINARY
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:22 lib
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 man
drwxr-xr-x 10 mysqladmin dba 4096 Jun 29 16:23 mysql-test
-rwxr-xr-x 1 mysqladmin dba 2496 Jan 19 2015 README
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 scripts
drwxr-xr-x 28 mysqladmin dba 4096 Jun 29 16:22 share
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 sql-bench
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 support-files
[root@hadoop001 mysql]#
##将真实的文件也进行修改
[root@hadoop001 local]# chown mysqladmin:dba mysql-5.6.23-linux-glibc2.5-x86_64
[root@hadoop001 local]# ll
total 304516
drwxr-xr-x. 2 root root 4096 Jun 27 09:22 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Jun 27 06:03 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
lrwxrwxrwx 1 mysqladmin dba 34 Jun 29 16:31 mysql -> mysql-5.6.23-linux-glibc2.5-x86_64
drwxr-xr-x 13 mysqladmin dba 4096 Jun 29 17:02 mysql-5.6.23-linux-glibc2.5-x86_64
-rw-r--r-- 1 root root 311771412 Jun 29 15:12 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Jun 24 23:04 sbin
drwxr-xr-x. 5 root root 4096 Jul 8 2016 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
[root@hadoop001 local]#
[root@hadoop001 mysql]# su - mysqladmin
[mysqladmin@hadoop001 ~]$ pwd
/usr/local/mysql
##创建binlog日志存储的文件夹
[mysqladmin@sht-sgmhadoopnn-01 ~]$ mkdir arch
##报错缺少 libaio,用root权限重新安装libaio
[mysqladmin@hadoop001 ~]$ scripts/mysql_install_db \
--user=mysqladmin \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 报错
[root@hadoop001 mysql]# yum install libaio 用root权限重新安装libaio
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.107-10.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================
Package Arch Version Repository Size
======================================================================
Installing:
libaio x86_64 0.3.107-10.el6 base 21 k
Transaction Summary
======================================================================
Install 1 Package(s)
Total download size: 21 k
Installed size: 34 k
Is this ok [y/N]: y
Downloading Packages:
libaio-0.3.107-10.el6.x86_64.rpm | 21 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libaio-0.3.107-10.el6.x86_64 1/1
/sbin/ldconfig: File /usr/lib/libiacpkmn.so.3 is empty, not checked.
Verifying : libaio-0.3.107-10.el6.x86_64 1/1
Installed:
libaio.x86_64 0:0.3.107-10.el6
Complete!
7.Again install
真正命令
[mysqladmin@hadoop001 ~]$ scripts/mysql_install_db \
--user=mysqladmin \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
To do so, start the server, then issue the following commands
要我们去启动,嗯成功了
8.Configure mysql service and boot auto start
[root@hadoop001 ~]# cd /usr/local/mysql
[root@hadoop001 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql #将服务文件拷贝到init.d下,并重命名为mysql
[root@hadoop001 mysql]# chmod +x /etc/rc.d/init.d/mysql #赋予可执行权限
[root@hadoop001 mysql]# chkconfig --del mysql #删除服务
[root@hadoop001 mysql]# chkconfig --add mysql #添加服务
[root@hadoop001 mysql]# chkconfig --level 345 mysql on # 代表开启自启动
[root@hadoop001 mysql]# vi /etc/rc.local
#!/bin/sh
BOOTSTRAP_CONF=/ucloud_boot/bsi-ihue3o.conf BOOTSTRAP_DIR=/ucloud_boot DISTRO=centos MAJOR=6 MINOR=6 /bin/bash /ucloud_boot/bootstrap.sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
su - mysqladmin -c "etc/init.d/mysql start " 编辑此内容
bash /usr/local/bin/set_irq_affinity.sh
9.Start mysql and to view process and listening
[root@hadoop001 mysql]# su - mysqladmin
[mysqladmin@hadoop001 ~]$ pwd
/usr/local/mysql
[mysqladmin@hadoop001 ~]$ ll
total 180
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 18:09 arch
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 bin
-rwxr-xr-x 1 mysqladmin dba 17987 Jan 19 2015 COPYING
drwxr-xr-x 5 mysqladmin dba 4096 Jun 29 18:09 data
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 docs
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:23 include
-rwxr-xr-x 1 mysqladmin dba 102315 Jan 19 2015 INSTALL-BINARY
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:22 lib
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 man
-rw-r--r-- 1 mysqladmin dba 943 Jun 29 18:01 my.cnf
-rw-r--r-- 1 mysqladmin dba 943 Jun 29 18:09 my-new.cnf
drwxr-xr-x 10 mysqladmin dba 4096 Jun 29 16:23 mysql-test
-rwxr-xr-x 1 mysqladmin dba 2496 Jan 19 2015 README
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 scripts
drwxr-xr-x 28 mysqladmin dba 4096 Jun 29 16:22 share
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 sql-bench
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 support-files
[mysqladmin@hadoop001 ~]$ rm -f my.cnf
[mysqladmin@hadoop001 ~]$ ll
total 176
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 18:09 arch
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 bin
-rwxr-xr-x 1 mysqladmin dba 17987 Jan 19 2015 COPYING
drwxr-xr-x 5 mysqladmin dba 4096 Jun 29 18:09 data
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:23 docs
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:23 include
-rwxr-xr-x 1 mysqladmin dba 102315 Jan 19 2015 INSTALL-BINARY
drwxr-xr-x 3 mysqladmin dba 4096 Jun 29 16:22 lib
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 man
-rw-r--r-- 1 mysqladmin dba 943 Jun 29 18:09 my-new.cnf
drwxr-xr-x 10 mysqladmin dba 4096 Jun 29 16:23 mysql-test
-rwxr-xr-x 1 mysqladmin dba 2496 Jan 19 2015 README
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 scripts
drwxr-xr-x 28 mysqladmin dba 4096 Jun 29 16:22 share
drwxr-xr-x 4 mysqladmin dba 4096 Jun 29 16:23 sql-bench
drwxr-xr-x 2 mysqladmin dba 4096 Jun 29 16:22 support-files
[mysqladmin@hadoop001 ~]$bin/mysqld_safe &
[1] 11219
[mysqladmin@hadoop001 ~]$ 190630 00:53:43 mysqld_safe Logging to '/usr/local/mysql/data/hostname.err'.
190630 00:53:43 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysqladmin@hadoop001 ~]$
[mysqladmin@hadoop001 ~]$ ps -ef|grep mysqld 查看进程
521 11219 11195 0 00:53 pts/5 00:00:00 /bin/sh bin/mysqld_safe
521 11864 11219 0 00:53 pts/5 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/hostname.err --pid-file=/usr/local/mysql/data/hostname.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
521 11893 11195 0 00:54 pts/5 00:00:00 grep mysqld
[root@hadoop001 ~]# netstat -nlp|grep 30939 查看端口号
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)#没有权限,用root账号查看
[root@hadoop001 ~]# netstat -nlp|grep 11864
tcp 0 0 :::3306 :::* LISTEN 11864/mysqld
unix 2 [ ACC ] STREAM LISTENING 10146392 11864/mysqld /usr/local/mysql/data/mysql.sock
#netstat -tulnp | grep mysql方法2#需用root权限查看#
[root@hadoop001 ~]# netstat -tulnp | grep mysql
tcp 0 0 :::3306 :::* LISTEN 11864/mysqld
[root@hadoop001 ~]# ps -ef|grep mysql
root 11194 10886 0 00:52 pts/5 00:00:00 su - mysqladmin
521 11219 11195 0 00:53 pts/5 00:00:00 /bin/sh bin/mysqld_safe
521 11864 11219 0 00:53 pts/5 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/hostname.err --pid-file=/usr/local/mysql/data/hostname.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306
root 11935 10871 0 00:58 pts/4 00:00:00 grep mysql
[mysqladmin@hadoop001 data]$ service mysqld start
Starting mysqld: [ OK ]
service mysql status
vi /etc/profile 配置全局环境变量
export JAVA_HOME=/usr/java/jdk1.8.0_45
export MYSQL_HOME=/usr/local/mysql 编辑
PATH=${MYSQL__HOME}/bin:${JAVA_HOME}/bin:$PATH
export PATH
[root@hadoop001 ~]# source /etc/profile 生效
[root@hadoop001 ~]# su - mysqladmin
[mysqladmin@hadoop001 ~]$ mysql
mysql>show databases; #命令
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123456
show databases' at line 3
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql>
mysql> use mysql; ##命令
Database changed
mysql> show tables;命令
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
mysql> select user,host,password from user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | hadoop001 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | hadoop001 | |
+------+-----------+----------+
6 rows in set (0.00 sec)
mysql> update user set password=password('123456') where user='root'; ##改密码
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> select user,host,password from user; ##
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | hadoop001 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| | localhost | |
| | hadoop001 | |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql>
mysql> delete from user where user=''; ##删除两行
Query OK, 2 rows affected (0.01 sec)
mysql> select user,host,password from user;##
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | hadoop001 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
只要MySQL关于用户操作 这是最后一步 不要忘记:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
vi .bash_profile 编辑配置
#stty erase ^H
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1
[mysqladmin@hadoop001 ~]$ exit
logout
[root@hadoop001 ~]# chown -R mysqladmin:dba /usr/local/mysql/*
[root@hadoop001 ~]# su - mysqladmin
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
hadoop001:mysqladmin:/usr/local/mysql:>
===============================
重新部署
service mysql stop
rm -rf /usr/local/mysql/arch/*
rm -rf /usr/local/mysql/data/*
scripts/mysql_install_db \
--user=mysqladmin \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
======================================
部署注意:
1 注意一些命令分别是在那些用户下执行
2 MySQL端口号是:3306
3遇到问题找log日志找error关键词
4MySQL文件夹下所有的用户用户组及其本目录的权限变更