下载mysql 安装

http://www.th7.cn/db/mysql/201304/29857.shtml

第一次接触服务器版Linux,也是第一次用命令行安装二进制mysql,两天一夜,比较痛苦。留做备忘!

首先,下载二进制版本的mysql包: http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz


准备工作:
1、下载mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
2、将软件拷贝到目的服务器/work/software目录下(使用FlashFXPPortable工具,传输模式设置为二进制)
3、在/work/software目录下输入以下命令,赋予可执行权限
    chmod 777 mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz


安装步骤
使用root账户登录服务器
1、解压tar.gz
tar –xzf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz

2、重命名解压的文件夹
mv mysql-5.6.10-linux-glibc2.5-x86_64 mysql

3、将mysql文件夹移动到/usr/local目录下
sudo mv mysql /usr/local

4、进入mysql目录
cd /usr/local/mysql

userdel -r mysql
groupdel mysql

5、增加mysql用户组
sudo groupadd mysql

6、增加mysql用户
sudo useradd -r -g mysql mysql

7、将mysql文件夹own及grp变更为mysql
sudo chown -R mysql .
sudo chgrp -R mysql .

8、执行mysql安装脚本
sudo scripts/mysql_install_db --user=mysql
(若未安装libaio包,会有一个报错提示,安装libaio-dev后,再运行脚本即可)
sudo apt-get install libaio-dev

9、将目录权限变更回来,仅保留data目录为mysql用户
sudo chown -R root .

sudo chown -R mysql data

10、将mysql配置文件拷贝到etc目录(全局配置)

注意:5.6版本的默认配置文件名称由原先的my-medium变更为了my-default。

sudo cp support-files/my-default.cnf /etc/my.cnf


11、启动mysql

sudo bin/mysqld_safe --user=mysql &


12、初始化mysql root用户密码

sudo bin/mysqladmin -u root password '密码文字'


13、复制mysql.server脚本到/etc/init.d(初始化服务,有些人喜欢改成mysqld,在这里改就可以)

sudo cp support-files/mysql.server /etc/init.d/mysql.server
sudo cp support-files/mysql.server /etc/init.d/mysqld


14、查看mysql运行状态

sudo service mysql.server status
如果运行正常,会显示 MySQL running。

如果显示 not running,应该是前面没有启动服务,可直接用service mysql.server start启动

sudo service mysql.server [status|start|stop]


15、让mysql开机启动[defaults],取消开机启动[remove]

ubuntu  sudo update-rc.d -f mysql.server defaults  [remove]

centos:
        
方法二:在mysql5目录下找到support-files目录将其中的mysql.server复制修改为/etc/init.d/mysqld
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld                             
service mysqld start  
chkconfig --level 35 mysqld on

16、将mysql/bin/mysql命令加入到用户命令中,或将mysql/bin目录加入path

加入用户命令:

sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

加入环境变量:

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


17、允许root用户远程登录

    1>进入mysql: mysql –u root –p

    2>改变数据库: use mysql;

    3>从任意主机登录: grant all privileges on *.* to root@"%" identified by "密码文字" with grant option;

    4>从指定主机登录: grant all privileges on *.* to root@"10.51.14.131" identified by "passw0rd" with grant option;
grant all privileges on *.* to root@"10.51.14.131" identified by "archermind" with grant option;

grant all privileges on *.* to root@"27.17.36.150" identified by "archermind1!2@3#4$" with grant option;

grant all privileges on *.* to root@"211.166.9.218" identified by "archermind1!2@3#4$" with grant option;

 
    grant all privileges on *.* to root@"10.52.12.89" identified by "archermind" with grant option;
    grant all privileges on *.* to root@"10.52.12.36" identified by "archermind" with grant option;

grant all privileges on *.* to root@"10.51.14.31" identified by "archermind" with grant option;
grant all privileges on *.* to root@"10.51.14.42" identified by "archermind" with grant option;
grant all privileges on *.* to root@"10.51.14.131" identified by "archermind" with grant option;


    5>授权生效: flush privileges;

    6>查看host为%授权是否添加: select * from user;

18、找个客户端试试

你可能感兴趣的:(下载mysql 安装)