CentOS 6.5 二进制安装MySQL 5.6
--------------------------------
下载MySQL5.6二进制包
mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz
安装相关依赖包
yum install libaio*
useradd mysql
安装mysql到/data/mysql/data下
tar zxvf mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz -C /data/
mv mysql-5.6.20-linux-glibc2.5-x86_64 mysql
修改mysql的各级文件夹和文件的创建者、创建组为mysql(注意语句后面有个.)
chown -R mysql.mysql /data/mysql
至此mysql已经安装完了,
但还需要初始化,初始化mysql表、test表、infomation表等。
/data/mysql/scripts/mysql_install_db --datadir=/data/mysql/data --basedir=/data/mysql --user=mysql --explicit_defaults_for_timestamp
-------------------------------------------------------------------------------------------------------------------------------------
拷贝启动脚本
cp /data/mysql/support-files/mysql.server /etc/init.d/mysqld
ln -s /data/mysql/include /usr/include/mysql
echo "/data/mysql/lib" > /etc/ld.so.conf.d/mysql.conf && ldconfig -v
ln -s /data/mysql/bin/mysql /usr/bin
修改配置文件my.cnf
cd /data/mysql
cp my.cnf /etc/my.cnf
vim /etc/my.cnf
[mysqld]中添加:
basedir = /data/mysql
datadir = /data/mysql/data
port = 3306
server_id = 1
-------------------------
启动mySQL服务
chkconfig mysqld on
service mysqld start
登陆MySQL并且删除空用户
mysql
mysql> SELECT user,host,password FROM mysql.user;
+------+-----------------------+----------+
| user | host | password |
+------+-----------------------+----------+
| root | localhost | |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+----------+
6 rows in set (0.00 sec)
设置密码()括号里面的为密码,用户名root
mysql> UPDATE mysql.user set password = PASSWORD(‘Zykj@password‘) WHERE user = ‘root‘;
mysql> SELECT user,host,password FROM mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
| root | localhost.localdomain | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
| root | 127.0.0.1 | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
| root | ::1 | *11B9ACA21786F766739D0EB1483C5F64212B81AC |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> DROP USER ‘‘@localhost;
mysql> FLUSH PRIVILEGES;
mysql> quit
---------------------MySQL安装完成-------------------------------
设置/修改 密码
mysql> grant all privileges on *.* to ‘root‘@‘localhost‘ identified by ‘Zykj@password‘ with grant option;
mysql> flush privileges;
原文地址:http://xmomo.blog.51cto.com/5994484/1939747