1.从网上下载MySQL的压缩包,以gz为结尾
2.打开机器通过rz命令上传到机器里
3.Check isnot install看机器是否装了MySQL,两个命令
ps -ef|grep mysqld
rpm -qa |grep -i mysql
4.tar和mv
切换到cd /usr/local 目录下解压。tar -xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
移动mv mysql-5.6.23-linux-glibc2.5-x86_64 mysql
5.Create group and user 创建组和用户
groupadd -g 101 dba
useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
id mysqladmin
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 #
copy 环境变量配置文件至mysqladmin用户的home目录中,为了以下步骤配置个人环境变量
[root@sht-sgmhadoopnn-01 local]# cp /etc/skel/.* /usr/local/mysql ###important
cp: omitting directory /etc/skel/.' cp: omitting directory
/etc/skel/…’
cp: omitting directory `/etc/skel/.mozilla’
6.Create /etc/my.cnf(640) 配置文件
cd /etc
touch my.cnf
vi my.cnf
innodb_buffer_pool_size = 2048M
修改为innodb_buffer_pool_size = 1024M
7.chown and chmod privileges and try first install
a.chown mysqladmin:dba /etc/my.cnf
b.chmod 640 /etc/my.cnf
c.chown -R mysqladmin:dba /usr/local/mysql
d.chmod -R 755 /usr/local/mysql
e.su - mysqladmin
f.pwd
创建binlog文件,归档文件
a.mkdir arch
*([mysqladmin@sht-sgmhadoopnn-01 ~]$ scripts/mysql_install_db ###importInstalling MySQL system tables…/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory #缺少libaio.so 包###see version[root@sht-sgmhadoopnn-01 local]# cat /proc/versionLinux version 2.6.18-164.11.1.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Wed Jan 20 07:32:21 EST 2010[root@sht-sgmhadoopnn-01 local]# rpm -qa |grep gcclibgcc-4.1.2-46.el5_4.2libgcc-4.1.2-46.el5_4.2)
切换到root用户执行
b.yum -y install libaio
8.Again install(切换到 mysqladmin用户执行)
a.scripts/mysql_install_db --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9.Configure mysql service and boot auto start(配置mysql的服务和开机自启动)
***用root用户来作
a. cd /usr/local/mysql
b. cp support-files/mysql.server /etc/rc.d/init.d/mysql (#将服务文件拷贝到init.d下,并重命名为mysql)
c. chmod +x /etc/rc.d/init.d/mysql(#赋予可执行权限)
*d.chkconfig --del mysql(删除服务)------一般第一次不用
e.chkconfig --add mysql(添加服务)
f.chkconfig mysql on
g.vi /etc/rc.local 写下面一句话
su - mysqladmin -c “/etc/init.d/mysql start --federated”
10.Start mysql and to view process and listening
a.su - mysqladmin
b.rm -rf my.cnf
c.which mysqld_safe
d.配置个人环境变量
ll -a
vi .bash_profile
添加
之后用. .bash_profile生效一下
或者用下图操作
e.mysqld_safe &(按回车直接后台)
f. 用root查看进程和端口号
ps -ef|grep mysqld
netstat -tulnp | grep mysql
service mysql status
11.Login mysql
切换到mysqladmin用户
a.mysql
a1.要是之前登录过有密码密码是123456就用mysql -uroot -p123456
b.show databases;
12.Update password and Purge user
mysql> use mysql
Database changed
mysql> select user,password,host from user;(语法)
mysql> update user set password=password(‘123456’) where user=‘root’;(中间有密码)
mysql> select user,password,host from user;
mysql> delete from user where user=’’;(删除用户,空密码)
mysql> select user,password,host from user;
mysql> flush privileges;(刷新权限)
Ctrl+z退出mysql
- Configure .bash_profile
14.创建用户
1.create database ruozedb;
2.grant all privileges on ruozedb.* to ruoze@’%’ identified by ‘123456’;(%表示ruoze这个用户的密码是任意的,可以改为其他的数字)
3.flush privileges;
%就是192.168.0.190
15.删除
rm -rf $MYSQL_HOME/arch/* binlog日志 恢复 或是主从同步
rm -rf $MYSQL_HOME/data/* 数据