Mysql 5.6.21 tar package installation practice under Linux

Environment: centos 6.4 x64

First download the mysql installation package
choose linux - Generic
choose again
After downloading, get the installation package mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
This package no longer needs make to compile the source code (really carry it), the previous mysql-5.6.4.tar.gz package is the source code package, you need to cmake first, then make & make install
Upload it to the /software directory of centos6.4 (you can change it to the directory you need, here is just a demonstration)
Log in to centos6.4 with ssh and start executing the following commands
 
1. Unzip the tar package

cd /software
tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.21-linux-glibc2.5-x86_64 mysql-5.6.21
 
2. Add users and groups

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql mysql-5.6.21
 
3. Install the database

on mysql
cd mysql-5.6.21/scripts
./mysql_install_db --user=mysql --basedir=/software/mysql-5.6.21 --datadir=/software/mysql-5.6.21/data
exit
 
4. Configuration file

cd /software/mysql-5.6.21/support-files
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql          #若mysql的安装目录是/usr/local/mysql,则可省略此步
修改文件中的两个变更值
basedir=/software/mysql-5.6.21
datadir=/software/mysql-5.6.21/data
 
5.配置环境变量

vim /etc/profile
export MYSQL_HOME="/software/mysql-5.6.21"
export PATH="$PATH:$MYSQL_HOME/bin"
保存退出
. /etc/profile
 
6.添加自启动服务

chkconfig --add mysql
chkconfig mysql on
 
7.启动mysql

service mysql start
 
8.登录mysql及改密码与配置远程访问

mysqladmin -u root password 'your_password'     #修改root用户密码
mysql -u root -p     #登录mysql,需要输入密码
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;     #允许root用户远程访问

mysql>FLUSH PRIVILEGES;     #刷新权限

mysql>exit
 
又装了一次此版本的mysql,发现root用户不能登录,提示没权限。使用mysqld_safe 登进去,发现user表居然是空的,没有一个用户,郁闷。
于是从其它地方导出了一份user表的sql语句,手动插入了一个用户,再登录就可以了。
附:
忘记root密码后,如何找回密码
cd $MYSQL_HOME
./bin/mysqld_safe --basedir=/data/mysql-5.6.21 --datadir=/data/mysql-5.6.21/data --skip-grant-tables &
mysql -u root mysql
UPDATE user SET password=PASSWORD("new_password") WHERE user='root';
FLUSH PRIVILEGES;

 

摘自:http://blog.csdn.net/zhanngle/article/details/41042631

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326610296&siteId=291194637