linux下jdk,mysql的部署

将jdk,mysql解压

1注意解压后,jdk的所属用户和用户组可能要修改

[root@hadoop000 java]# ll
total 169220
drwxr-xr-x. 8 uucp  143      4096 Apr 11  2015 jdk1.8.0_45
-rw-r--r--. 1 root root 173271626 Oct 24 17:25 jdk-8u45-linux-x64.gz
[root@hadoop000 java]# chown -R root:root jdk1.8.0_45/

2配置java环境文件/etc/profile,生效

[root@hadoop000 java]# vi /etc/profile
[root@hadoop000 java]# source /etc/profile
[root@hadoop000 java]# which java
/usr/java/jdk1.8.0_45/bin/java
[root@hadoop000 java]# java -version
java version "1.8.0_45"

3如果不熟悉环境,可以先检查一下mysql有没有被安装过

[root@hadoop000 java]# ps -ef|grep mysqld
root      2580  2428  0 16:09 pts/2    00:00:00 grep mysqld
[root@hadoop000 java]# rpm -qa | grep -i mysql  忽略大小写
mysql-libs-5.1.71-1.el6.x86_64

4创建mysql用户和组

[root@hadoop000 local]# groupadd -g 101 dba
[root@hadoop000 local]# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
[root@hadoop000 local]# id mysqladmin
uid=514(mysqladmin) gid=101(dba) groups=101(dba),0(root)
[root@hadoop000 local]# usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

这里先指定组名和对应的数字,514指的是创建的用户id就是514,-g指定用户的主组,-G副组,-d用户创建之后的家目录,用户名称叫做mysqladmin。这里的警告是丢失环境变量文件。
usermod是用户已存在,修改一下。

5复制环境配置文件到mysqladmin用户的home目录

[root@hadoop000 local]# cp /etc/skel/.* /usr/local/mysql
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: omitting directory `/etc/skel/.gnome2'
cp: omitting directory `/etc/skel/.mozilla'

6创建mysql配置文件 /etc/my.cnf(640) 这个是权限

[root@hadoop000 local]# cd /etc/
[root@hadoop000 etc]# touch my.cnf
[root@hadoop000 etc]# vi my.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

修改:
innodb_buffer_pool_size = 1024M

7修改配置文件的用户和用户组

[root@hadoop000 etc]# chown mysqladmin:dba /etc/my.cnf
[root@hadoop000 etc]# chmod 640 /etc/my.cnf
[root@hadoop000 etc]# ll my.cnf
-rw-r-----. 1 mysqladmin dba 2219 Oct 28 18:51 my.cnf

修改家目录的

[root@hadoop000 etc]# chown -R mysqladmin:dba /usr/local/mysql
[root@hadoop000 etc]# chmod -R 755 /usr/local/mysql

切换看下

[root@hadoop000 etc]# su - mysqladmin
[mysqladmin@hadoop000 ~]$ pwd
/usr/local/mysql

8创建binlog文件,并安装libaio包

[mysqladmin@hadoop000 ~]$ mkdir arch
[mysqladmin@hadoop000 ~]$ yum -y install libaio
[mysqladmin@hadoop000 ~]$ scripts/mysql_install_db  --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

9设置mysql服务开机自启动等

[root@hadoop000 local]# cd /usr/local/mysql
[root@hadoop000 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
[root@hadoop000 mysql]# chmod +x /etc/rc.d/init.d/mysql
[root@hadoop000 mysql]# chkconfig --del mysql
[root@hadoop000 mysql]# chkconfig --add mysql
[root@hadoop000 mysql]# chkconfig  mysql on
[root@hadoop000 mysql]# vi /etc/rc.local

增加一句

su - mysqladmin -c "/etc/init.d/mysql start --federated"

10
删了mysql下的my.cnf,因为我们配置的再etc目录下

[mysqladmin@hadoop000 ~]$ rm -rf my.cnf

个人环境变量配置

[mysqladmin@hadoop000 ~]$ vi .bash_profile 

里面加入

export MySQL_HOME=/usr/local/mysql
export PATH=$ MYSQL_HOME/bin:$ PATH

退出重进

[mysqladmin@hadoop000 ~]$ exit
logout
There are stopped jobs.
[mysqladmin@hadoop000 ~]$ su -mysqladmin
su: invalid option -- 'y'
Try `su --help' for more information.
[root@hadoop000 etc]# su - mysqladmin
[mysqladmin@hadoop000 ~]$ echo $ MYSQL_HOME
/usr/local/mysql
[mysqladmin@hadoop000 ~]$ mysqld_safe &
[1] 6337
查下进程端口号等
[mysqladmin@hadoop000 ~]$ ps -ef|grep mysqld
514       3448     1  0 Oct28 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
[mysqladmin@hadoop000 ~]$ netstat -nlp|grep mysql
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 :::3306                     :::*                        LISTEN      4091/mysqld         
unix  2      [ ACC ]     STREAM     LISTENING     35117  4091/mysqld         /usr/local/mysql/data/mysql.sock
[root@hadoop000 mysql]# service mysql status
MySQL running (4091)                                       [  OK  ]

11
进入mysql

[mysqladmin@hadoop000 ~]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

12
设置mysql账号密码

mysql> use mysql;
Database changed

查看当前database

mysql> select database();
+------------+
| database() |
+------------+r
| mysql      |
+------------+

看下有那些表

show tables;

mysql> select user,password,host from user;
+------+----------+-----------+
| user | password | host      |
+------+----------+-----------+
| root |          | localhost |
| root |          | hadoop000 |
| root |          | 127.0.0.1 |
| root |          | ::1       |
|      |          | localhost |
|      |          | hadoop000 |
+------+----------+-----------+
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,password,host from user;
+------+-------------------------------------------+-----------+
| user | password                                  | host      |
+------+-------------------------------------------+-----------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost |

mysql> delete from user where user='';
Query OK, 2 rows affected (0.00 sec)

创建用户

mysql> create user root@'%' identified by '123456';

刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

重进要密码

[mysqladmin@hadoop000 ~]$ mysql -uroot -p123456

创建db,给用户赋予查看db的权限

mysql> create database ruozedb;
Query OK, 1 row affected (0.00 sec)

给ruoze这个用户(可以通过什么ip)赋予所有权限争对ruozedb里的所有表

mysql> grant all privileges on ruozedb.* to ruoze@'127.0.0.1' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

注意这里因为上面是127,这里也要赋值

[mysqladmin@hadoop000 ~]$ mysql -uruoze -p123456 -h127.0.0.1

因为之后要去win装mysql图形化界面,所以这里还是
这样不管是哪里的ip都能连数据库,%的意义

mysql> update user set host='%' where user='ruoze';
mysql> flush privileges;

用dbeaver连接报错
查看下,有问题

mysql> show grants for 'ruoze'@'%';

据说是由于修改ip导致不识别,需要配置网卡
window–VM8–>linux mysql
192.168.137.1
这里需要补充一下知识,关于网段和普通ip,如果公司电脑的ip是变化的,可以将账户的ip设置成一个网段
172.16.110.100 mysql
‘user’@‘172.16.110.0’ 网段

注意生产连接的时候,-p之后不直接输入密码,会泄露。-p时密码,-P是端口号。

删了重搞

mysql> drop user ruoze@'%'
    -> ;
mysql> grant all privileges on ruozedb.* to ruoze@'%' identified by '123456';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值