mysql离线安装

在线安装:

yum -y install mysql-server mysql mysql-devel

 

离线安装:

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

jdbc下载

http://dev.mysql.com/downloads/connector/j/  

1,复制到指定目录

mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql

2,创建mysql用户和组

groupadd mysql

useradd -r -g mysql mysql -d /usr/local/mysql

passwd mysql

3,修改目录权限

chown -R mysql:mysql /usr/local/mysql

4,安装数据库

su mysql

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

如有报错:

1)scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory。
需要安装perl以及perl-devel.执行命令:yum –y install perl perl-devel

2),Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
安装:yum install libaio* -y

5,.复制mysql配置文件

cd /usr/local/mysql/support-files

cp my-default.cnf /etc/my.cnf

6,添加系统服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

chkconfig mysql on

7,.添加环境变量

export MYSQL_HOME=/usr/local/mysql

export PATH=$PATH:$MYSQL_HOME/bin

source /etc/profile

8,启动mysql

service mysql start

9,设置root密码

mysqladmin -u root password '123456'

10,设置默认端口

vi /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

port=3306

server_id=1

socket=/tmp/mysql.sock

11,允许所有外部链接访问(可选)

select host,user,authentication_string from user;

mysql -u root -p

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

FLUSH PRIVILEGES;

# yum install gcc gcc-c++ autoconf automake

你可能感兴趣的:(数据库)