mysql安装步骤(2)直接安装

一、准备文件

mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
官网下载链接

二、解压

1
$ tar mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

三、MySQL安装

1、进入mysql的安装路径

1
2
$ cd mysql-5.6.36-linux-glibc2.5-x86_64/
$ mkdir datadir

2、复制默认配置文件

1
$ cp support-files/my-default.cnf ./my.cnf

3、修改配置文件my.cnf

1
2
3
4
5
basedir = /home/sun_zeming/mysql/mysql-5.6.36-linux-glibc2.5-x86_64
datadir = /home/sun_zeming/mysql/mysql-5.6.36-linux-glibc2.5-x86_64/datadir
port = 6660
# server_id = .....
socket = /home/sun_zeming/mysql/mysql-5.6.36-linux-glibc2.5-x86_64/mysql.sock

4、安装mysql

1
$ ./scripts/mysql_install_db --user=root --defaults-file=/home/sun_zeming/mysql/mysql-5.6.36-linux-glibc2.5-x86_64/my.cnf

四、启动MySQL

1
$ ./bin/mysqld --defaults-file=/home/sun_zeming/mysql/mysql-5.6.36-linux-glibc2.5-x86_64/my.cnf

五、MySQL授权

1、设置root用户密码

1
$ ./bin/mysqladmin –h127.0.0.1 –P6660 -u root password "123456"

2、登录mysql

1
$ ./bin/mysql –h127.0.0.1 -P6660 -uroot -p123456

3、授权

1
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
>